Skip to content

Instantly share code, notes, and snippets.

@martinandersen3d
Forked from wycliffepeart/merge-object.js
Created November 25, 2017 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinandersen3d/2e4479070aad8757bbb5f55ab5985305 to your computer and use it in GitHub Desktop.
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.
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