javascript - What is the difference between passing parameters and not passing parameters in the method Object()?
过去多啦不再A梦
过去多啦不再A梦 2017-07-05 11:08:24
0
2
852

For example, what is the difference between target = Object(target) and target = Object() or target = new Object()?

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;
  };
}
过去多啦不再A梦
过去多啦不再A梦

reply all(2)
Peter_Zhu

If you don’t give parameters, it will be an empty object. . .

为情所困

https://developer.mozilla.org...This article explains it very clearly

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template