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).
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn