Created
January 22, 2015 03:34
-
-
Save ianaya89/aa7ef33766f28f6ca2f2 to your computer and use it in GitHub Desktop.
Extend an object with Vanilla JS
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
var extend = function(out) { | |
out = out || {}; | |
for (var i = 1; i < arguments.length; i++) { | |
if (!arguments[i]) | |
continue; | |
for (var key in arguments[i]) { | |
if (arguments[i].hasOwnProperty(key)) | |
out[key] = arguments[i][key]; | |
} | |
} | |
return out; | |
}; | |
extend({}, objA, objB); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment