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. 360瀏覽器與IE瀏覽器有何區(qū)別???2. mysql 怎么做到update只更新一行數(shù)據(jù)?3. javascript - 新浪微博網(wǎng)頁版的字數(shù)限制是怎么做的4. node.js - mysql如何通過knex查詢今天和七天內(nèi)的匯總數(shù)據(jù)5. mysql 插入數(shù)值到特定的列一直失敗6. python - 在使用Pycharm時經(jīng)常看到如下的樣式,小括號里紅色的部分是什么意思呢?7. javascript - 用jsonp抓取qq音樂總是說回調(diào)函數(shù)沒有定義8. 怎么在網(wǎng)頁中設(shè)置圖片進行左右滑動9. sublime可以用其他編譯器替換嗎?10. python 合并dict
