- 
      
- 
        Save osiyuk/c13b6c9a9fd1acdc87570118355aaf98 to your computer and use it in GitHub Desktop. 
    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 (!Object.assign) { | |
| Object.defineProperty(Object, 'assign', { | |
| enumerable: false, | |
| configurable: true, | |
| writable: true, | |
| value: function (target) { | |
| 'use strict'; | |
| if (target === undefined || target === null) { | |
| throw new TypeError('Cannot convert first argument to object'); | |
| } | |
| var next, keys, len, key, desc, i, j; | |
| target = Object(target); | |
| for (i = 1; i < arguments.length; i++) { | |
| next = arguments[i]; | |
| if (next === undefined || next === null) { | |
| continue; | |
| } | |
| next = Object(next); | |
| keys = Object.keys(next); | |
| for (j = 0, len = keys.length; j < len; j++) { | |
| key = keys[j]; | |
| desc = Object.getOwnPropertyDescriptor(next, key); | |
| if (desc !== undefined && desc.enumerable) | |
| target[key] = next[key]; | |
| } | |
| } | |
| return target; | |
| } | |
| }); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment