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);
网友评论