// new
const myNew = function (constructor, ...args) {
if (typeof constructor !== 'function') {
throw new TypeError('construtor must be FUNCTION type')
} else {
const ret = {}
Object.setPrototypeOf(ret, constructor.prototype)
constructor.call(ret, ...args)
return ret
}
}
obj1 = myNew(function (name) {
this.name = name
}, 'Ben')
console.log(obj1)