should not call method slice on [object object]

It seems that you want to skip some object in for...in by setting enumerable false to it.
But IE8 does not have Object.defineProperty.

So the following built codes in my enrty file (vendor.js) throw en error in IE8,
Object doesn't support property or method 'slice'.

for (moduleId in moreModules) {
  var _m = moreModules[moduleId];

  // Check if module is deduplicated
  switch (typeof _m) {
    case "object":
      // Module can be created from a template
      modules[moduleId] = (function(_m) {
        // in IE8 _m maybe [object object] some time, but not [object Array]
        var args = _m.slice(1),
          templateId = _m[0];
        return function(a, b, c) {
          modules[templateId].apply(this, [a, b, c].concat(args));
        };
      }(_m));
      break;
    case "function":
      // Normal module
      modules[moduleId] = _m;
      break;
    default:
      // Module is a copy of another module
      modules[moduleId] = modules[_m];
      break;
  }
}

Author: Fantashit

1 thought on “should not call method slice on [object object]

Comments are closed.