javascript - 方法Object()里面?zhèn)鲄?shù)和不傳參數(shù)有什么區(qū)別?
問題描述
比如這里target = Object(target)和target = Object()或者target = new Object()有什么區(qū)別?
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; };}
問題解答
回答1:你不給參數(shù)的話他就是個(gè)空對(duì)象。。。
回答2:https://developer.mozilla.org...這篇文章講得很清楚
相關(guān)文章:
1. 關(guān)于nginx location配置的問題,root到底是什么2. docker鏡像push報(bào)錯(cuò)3. angular.js - angular內(nèi)容過長展開收起效果4. 關(guān)于docker下的nginx壓力測試5. angular.js - angularjs的自定義過濾器如何給文字加顏色?6. python 怎樣用pickle保存類的實(shí)例?7. 大家好,請(qǐng)問在python腳本中怎么用virtualenv激活指定的環(huán)境?8. python的前景到底有大?如果不考慮數(shù)據(jù)挖掘,機(jī)器學(xué)習(xí)這塊?9. 并發(fā)模型 - python將進(jìn)程池放在裝飾器里為什么不生效也沒報(bào)錯(cuò)10. python2安裝失敗
