function _new() {
let newObj = {};
let Constructor = Array.prototype.shift.call(arguments);
//这里为什么不能直接 let Constructor = arguments[0]呢?
newObj.__proto__ = Constructor.prototype;
Constructor.apply(newObj, arguments);
return newObj;
}
这里的目的是取第一个参数作为构造函数,然后后面参数作为构造参数。
如果你直接取第一个参数,就会把构造函数也作为构造函数的参数扔进去,所有不能直接取。