Skip to content

Instantly share code, notes, and snippets.

@WebReflection
Last active November 1, 2016 06:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WebReflection/10404826 to your computer and use it in GitHub Desktop.
Save WebReflection/10404826 to your computer and use it in GitHub Desktop.
ES3 compatible Object.assign
if (!('assign' in Object)) {
Object.assign = function(has){
'use strict';
return assign;
function assign(target, source) {
for (var i = 1; i < arguments.length; i++) {
copy(target, arguments[i]);
}
return target;
}
function copy(target, source) {
for (var key in source) {
if (has.call(source, key)) {
target[key] = source[key];
}
}
}
}({}.hasOwnProperty);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment