Getting Error: Object doesn’t support property or method ‘assign’

As others have mentioned, the Object.assign() method is not supported in IE, but there is a polyfill available, just include it “before” your plugin declaration:

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;
  };
}

From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign

Test page: http://jsbin.com/pimixel/edit?html,js,output (just remove the polyfill to get the same error you’re getting on your page).

Leave a Comment