-
-
Save martinandersen3d/2e4479070aad8757bbb5f55ab5985305 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 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