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

构造函数为什么不生效?

构造函数为什么不生效?

缥缈止盈 2018-09-14 13:13:12
function Person(name,age,job) {       this.name=name;// 要用构造函数起名时候要首字母大写      this.age=age;    this.job=job;    this.sayName=function () {        alert(this.name);    };}var person3=new Object("Nicholas",29,"Software Engineer");var person4=new Object('Greg',27,"Doctor");console.log(person3.name); // undefinedconsole.log(person3.constructor==Person); //falseconsole.log(person4.constructor==Person); //falseconsole.log(person3 instanceof Object); //trueconsole.log(person3 instanceof Person); //falseconsole.log(person4 instanceof Object); //trueconsole.log(person4 instanceof Person); //false
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 606 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

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

帮助反馈 APP下载

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

公众号

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