快捷导航

js构造继承问题

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);这两句有什么区别吗?为什么第一种写法无法继承而第二种可以呢?感觉上是一回事呀。

免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。

版权声明:作者保留权利,不代表本站立场。

回复

使用道具 举报

参与会员1

第一句是 jis的赋值  this.pobj(name)是实参   传参
回复

使用道具 举报

可能感兴趣的问答

发新帖
  • 微信访问
  • 手机APP