Object.prototype.new = function(...rest) {
const contructor = this
const obj = new Object()
contructor.apply(obj, rest)
obj.__proto__ = this.prototype
return obj
}
function Person(name, age) {
this.name = name
this.age = age
}
Person.prototype.getName = function() {
return this.name
}
const p = Person.new('kity', 18)
console.log(p.__proto__ === Person.prototype)
console.log(p.getName())
console.log(p instanceof Person)