Created
August 5, 2015 07:03
-
-
Save asvny/9459b066868612cfe8b8 to your computer and use it in GitHub Desktop.
Object assign
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
if (!Object.prototype.assign) { | |
Object.prototype.assign = function() { | |
var args = [].slice.call(arguments), | |
target = args.shift(); | |
return args.reduce(function(base, obj) { | |
Object.keys(obj).forEach(function(prop) { | |
if (obj.hasOwnProperty(prop)) { | |
base[prop] = obj[prop]; | |
} | |
}); | |
return base; | |
}, target); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment