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
添加回答
举报
0/150
提交
取消