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

为什么一个true一个false,我觉得都是false啊!

为什么一个true一个false,我觉得都是false啊!

yuqingzhijie3596863 2016-11-16 10:29:07
function Person(name, age, job){ this.name = name; this.age = age; this.job =job; this.sayName = sayName; } function sayName(){ alert(this.name); } var person1 = new Person("wo", 29, "software Engineer"); var person2 = new Person("ta", 27, "Doctor"); alert(person1.sayName == person2.sayName);         //~~~~~~~~~~~~~~~~~~·true//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~function Person(name, age, job){this.name = name;this.age = age;this.job = job;this.sayName = new Function("alert(this.name)"); // 与声明函数在逻辑上是等价的}var person1 = new Person("wo", 29, "software Engineer"); var person2 = new Person("ta", 27, "Doctor");alert(person1.sayName == person2.sayName);       //~~~~~~~~~~~~~~~~~~~~~~~~false
查看完整描述
  • 1 回答
  • 0 关注
  • 1949 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信