Created
September 17, 2013 18:06
-
-
Save katowulf/6598238 to your computer and use it in GitHub Desktop.
A simple extend function for JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Race condition prevention provided by single-threaded model of JS in browsers?
(in this use scenario: http://jsfiddle.net/katowulf/9GEFf/)