SOURCE

function newObject() {
    let obj = {}
    let Ctor = arguments[0]
    let args = [...arguments].slice(1)

    obj.__proto__ = Ctor.prototype
    obj.__proto__.constructor = Ctor

    let rec = Ctor.apply(obj, args)

    return typeof rec === 'object' ? rec : obj
}

// demo
function Dog(name, color, age) {
  this.name = name;
  this.color = color;
  this.age = age;
}

Dog.prototype={
  getName: function() {
    return this.name
  }
}

var dog = newObject(Dog, '二黑', '白色', 5)

console.log(dog)
console.log(Dog)
console 命令行工具 X clear

                    
>
console