为了账号安全,请及时绑定邮箱和手机立即绑定

Uncaught TypeError is not a constructor?

Uncaught TypeError is not a constructor?

守着星空守着你 2018-09-11 13:33:21
首先function a(){    this.a1="haha"; } b=new a();console.log(b);可以正常运行的毋庸置疑。那么改一下a=function (){    this.a1="haha"; } b=new a();console.log(b);同样可以正常运行。再改一下a=function (){    this.a1=function (){        this.a2="haha";     };     e=new this.a1();    console.log(e); } b=new a();还是可以正常运行。但是再改一下就不行了a=function (){    this.a1=function (){        this.a2="haha";     }; } b=new a(); e=new a.a1();chrome控制台提示Uncaught TypeError: a.a1 is not a constructor想问一下这是什么原因?
查看完整描述

1 回答

?
侃侃无极

TA贡献2051条经验 获得超10个赞

a里面没有a1

https://img1.sycdn.imooc.com//5bcfe3f30001321f02110337.jpg

查看完整回答
反对 回复 2018-10-24
  • 1 回答
  • 0 关注
  • 4540 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号