Created
April 24, 2018 02:14
-
-
Save jrrio/4dd2bec652dd642517a390172be27da2 to your computer and use it in GitHub Desktop.
Object.assign() polyfill for IE11
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
/** | |
* Object.assign() polyfill for IE11 | |
* @see <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign> | |
*/ | |
if (typeof Object.assign != "function") { | |
Object.defineProperty(Object, "assign", { | |
value: function assign(target, varArgs) { | |
"use strict"; | |
if (target == null) { | |
throw new TypeError("Cannot convert undefined or null to object"); | |
} | |
var to = Object(target); | |
for (var index = 1; index < arguments.length; index++) { | |
var nextSource = arguments[index]; | |
if (nextSource != null) { | |
for (var nextKey in nextSource) { | |
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { | |
to[nextKey] = nextSource[nextKey]; | |
} | |
} | |
} | |
} | |
return to; | |
}, | |
writable: true, | |
configurable: true | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment