Was ist zum Beispiel der Unterschied zwischen target = Object(target) und target = Object() oder 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;
};
}
你不给参数的话他就是个空对象。。。
https://developer.mozilla.org...这篇文章讲得很清楚