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); // undefined
console.log(person3.constructor==Person); //false
console.log(person4.constructor==Person); //false
console.log(person3 instanceof Object); //true
console.log(person3 instanceof Person); //false
console.log(person4 instanceof Object); //true
console.log(person4 instanceof Person); //false
相关分类