Last active
December 8, 2020 03:32
-
-
Save wycliffepeart/c6520bc1c340fd0c59af5b7cb59ea610 to your computer and use it in GitHub Desktop.
Javascript Object.assign Alternative . The mergeObject() method is used to copy the values of all enumerable own properties from one or more source objects to a target object. It will return the target object.
This file contains hidden or 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 mergeObject(target) { | |
for (var i = 1; i < arguments.length; i++) { | |
var source = arguments[i]; | |
for (var key in source) { | |
if (source.hasOwnProperty(key)) { | |
target[key] = source[key]; | |
} | |
} | |
} | |
return target; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment