Skip to content

Instantly share code, notes, and snippets.

@katowulf
Created September 17, 2013 18:06
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • 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