Last active
November 1, 2016 06:32
-
-
Save WebReflection/10404826 to your computer and use it in GitHub Desktop.
ES3 compatible Object.assign
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
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