您的位置:首頁技術文章
文章詳情頁

javascript - 方法Object()里面傳參數和不傳參數有什么區別?

瀏覽:104日期:2023-02-09 18:56:07

問題描述

比如這里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; };}

問題解答

回答1:

你不給參數的話他就是個空對象。。。

回答2:

https://developer.mozilla.org...這篇文章講得很清楚

標簽: JavaScript
相關文章:
国产综合久久一区二区三区