javascript - 方法Object()裡面傳參數和不傳參數有什麼差別?
过去多啦不再A梦
过去多啦不再A梦 2017-07-05 11:08:24
0
2
729

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

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!