+ 2
What is "instance" of an object?
2 Answers
+ 6
First, you define an object (using an object constructor):
function Person(firstName, lastName, age) {
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
}
Now, you may create as many as you need of "real" persons using that object constructor and each person would be a new "instance" of the object 'Person':
var john = new Person("John", "Doe", 45);
- 4
bom dia đđ”