const _new = function (func, ...args) {
if (typeof func !== 'function') {
throw 'func must be a function'
}
let obj = {}
obj.__proto__ = func.prototype
let result = func.apply(obj, args)
return !!result&& typeof result === 'object' || typeof result === 'function' ? result : obj
}
let Person = function (name, sex) {
this.name = name
this.sex = sex
}
Person.prototype.showInfo = function () {
console.log(this.name, this.sex)
}
let p1 = _new(Person, '111', 'sex')
console.log(p1)
console.log(p1.showInfo)
n typeof res === "object" || typeof res === "function" ? res : instance;
}