new的本质
如果new运算符是一个方法而不是一个运算符.
Function.prototype.new = function(){
// 创建一个新对象that,新对象继承自构造函数
var that = Object.create(this.prototype);
// 用新函数的指针that,调用构造函数,并得到返回值other
var other = this.apply(that,arguments);
// 判断构造函数中,return的是对象,是则返回,不是则返回新对象that
return (typeof other === ‘object’ && other || that);
}
var child = Parent.new(arguments); –> child = new Parent(arguments);