【Javascript问题系列】

时间:2015-04-17 10:58:06   收藏:0   阅读:163
 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 呢~,难道创建实例的时候没有调用原型构造函数么?

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!