Skip to content

Instantly share code, notes, and snippets.

@wycliffepeart
Last active December 8, 2020 03:32
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save wycliffepeart/c6520bc1c340fd0c59af5b7cb59ea610 to your computer and use it in GitHub Desktop.
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.
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