this.name = name;
this.age = age;
}
//Define person prototype, the attributes in the prototype can be referenced by custom objects
person.prototype = {
🎜>
Copy code
The code is as follows:
This requires the introduction of another concept - Prototype, we can simply think of prototype as a template. The newly created custom objects are all copies of this template (prototype) (actually not a copy but a link, but this link is not It can be seen that it feels like a copy to people).