Last active
August 31, 2018 15:09
-
-
Save macghriogair/6de5b6e8fe6feb7cdd2ed3555a13bfeb to your computer and use it in GitHub Desktop.
[polyfill object assign] #polyfill
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 (typeof Object.assign !== 'function') { | |
Object.assign = function(target) { | |
'use strict' | |
if (target == null) { | |
throw new TypeError('Cannot convert undefined or null to object') | |
} | |
target = Object(target) | |
for (var index = 1; index < arguments.length; index++) { | |
var source = arguments[index] | |
if (source != null) { | |
for (var key in source) { | |
if (Object.prototype.hasOwnProperty.call(source, 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