Skip to content

Instantly share code, notes, and snippets.

@katowulf
Created September 17, 2013 18:06
Show Gist options
  • Save katowulf/6598238 to your computer and use it in GitHub Desktop.
Save katowulf/6598238 to your computer and use it in GitHub Desktop.
A simple extend function for JavaScript
function extend(base) {
var parts = Array.prototype.slice.call(arguments, 1);
parts.forEach(function (p) {
if (p && typeof (p) === 'object') {
for (var k in p) {
if (p.hasOwnProperty(k)) {
base[k] = p[k];
}
}
}
});
return base;
}
@vucalur
Copy link

vucalur commented Sep 1, 2016

Race condition prevention provided by single-threaded model of JS in browsers?
(in this use scenario: http://jsfiddle.net/katowulf/9GEFf/)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment