1 function.methos("new", function () { 2 //新创建一个对象,它继承了构造器的原型对象。 3 var that = Object.create(this.prototype); //此时,this是指向Function构造器的。 4 //调用构造器,绑定this对象到新对象that上 5 var other = this.apply(that, argument); //此时,this对象指向that对象。 6 //如果它的返回值不是一个对象,就返回新的对象。 7 return (typeof other === "object" && other) || that; 8 });
new一个新对象
猜你喜欢
转载自www.cnblogs.com/vicky24k/p/11762753.html
今日推荐
周排行