function Person(name,age){
this.name = name;
this.age = age;
}
Person.prototype.sayName = function(){
alert(this.name);
}
function myNew(func, ...args) {
const obj ={};
obj.__proto__ = func.prototype;
let result = func.apply(obj,args);
return result instanceof Object ? result : obj;
}
const lucy = myNew(Person,'lucy',23);
console.log(lucy);
lucy.sayName();