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ù)的話他就是個空對象。。。
回答2:https://developer.mozilla.org...這篇文章講得很清楚
相關(guān)文章:
1. python - 如何對列表中的列表進行頻率統(tǒng)計?2. javascript - 如何用最快的速度C#或Python開發(fā)一個桌面應(yīng)用程序來訪問我的網(wǎng)站?3. thinkPHP5中獲取數(shù)據(jù)庫數(shù)據(jù)后默認(rèn)選中下拉框的值,傳遞到后臺消失不見。有圖有代碼,希望有人幫忙4. 求救一下,用新版的phpstudy,數(shù)據(jù)庫過段時間會消失是什么情況?5. django - Python error: [Errno 99] Cannot assign requested address6. Python2中code.co_kwonlyargcount的等效寫法7. python小白,關(guān)于函數(shù)問題8. linux運維 - python遠程控制windows如何實現(xiàn)9. python小白 關(guān)于類里面的方法獲取變量失敗的問題10. mysql數(shù)據(jù)庫做關(guān)聯(lián)一般用id還是用戶名
