方法Object()里面传参数和不传参数有什么区别?

比如这里target = Object(target)和target = Object()或者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;

  };

}


繁星coding
浏览 444回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript