1
function Person(name, age, job) {
2
this.name = name;
3
this.age = age;
4
this.job = job;
5
this.sayName =
function () {
6 console.log(
this.name);
7 };
8 }
9
10
var person1 =
new Person("Nicholas", 29, "Software Engineer");
11
var person2 =
new Person("Greg", 27, "Doctor");
12
13 person1.sayName();
14 person2.sayName();
15
16 console.log(person1.constructor);
17 console.log(person2.constructor);
18 console.log(person1
instanceof Object);
19 console.log(person1
instanceof Person);
20 console.log(person2
instanceof Object);
21 console.log(person2
instanceof Person);
转载于:https://www.cnblogs.com/qzsonline/archive/2012/03/16/2400172.html