new運算符作用;1.執(zhí)行函數(shù);2.自動創(chuàng)建一個空對象; 3.把創(chuàng)建的對象指向另外一個對象;
function _new(constructor,...arg){
let obj = {};
constructor.call(obj,..arg)
obj.__proto__ = constructor.prototype;
return obj
}
new運算符作用;1.執(zhí)行函數(shù);2.自動創(chuàng)建一個空對象; 3.把創(chuàng)建的對象指向另外一個對象;
function _new(constructor,...arg){
let obj = {};
constructor.call(obj,..arg)
obj.__proto__ = constructor.prototype;
return obj
}