new
2020-10-20 本文已影响0人
bestCindy
function fn(name, age) {
this.name = name;
this.age = age;
}
function newOperator(cons) {
let obj = Object.create(cons.prototype);
let newArgs = [...arguments].splice(1)
cons.apply(obj, newArgs);
return obj;
}
let newObj = newOperator(fn, "Cindy", "18");
console.log(newObj);