1 function Box(){} 2 Box.prototype = { 3 constructor : function (){ 4 console.log('this is constructor'); 5 }, 6 name : 'name', 7 age : 25, 8 run : function (){ 9 return this.name + this.age + 'running';10 }11 }12 var box = new Box();
对Box的原型构造函数重写,为什么创建Box的实例,不会输出 this is constructor 呢~,难道创建实例的时候没有调用原型构造函数么?
原标题:【Javascript问题系列】
关键词:JavaScript