function parent(name){ this.name=name; this.say=function(){ console.log("dad's name: "+this.name); } } function child(name){ this.pObj=parent(name); this.pObj=parent; this.pObj(name); this.sayC=function(){ console.log("child's name: "+this.name); } }
想知道这段代码中的
this.pObj=parent(name);
这一句和
this.pObj=parent; this.pObj(name);
这两句有什么区别吗?为什么第一种写法无法继承而第二种可以呢?感觉上是一回事呀。
JH鹰
相关分类