SOURCE

function New(func) {
  var res = {};
  if(func.prototype !== null) {
    res.__proto__ = func.prototype;
  }
  var ret = func.apply(res, Array.prototype.slice.call(arguments,1));
  if((typeof ret === 'object' || typeof ret === 'function') && ret !== null) {
    return ret;
  }
  return res;
}


var Animal = function(name,age) {
  this.name = name;
  this.age = age;
}
Animal.prototype.call = function() {
  alert('hello')
}

var a1 = new Animal('cat',10)

var a2 = New(Animal,'cat',10)

console 命令行工具 X clear

                    
>
console