Home  >  Article  >  Web Front-end  >  OOP inheritance implementation of js (must read)

OOP inheritance implementation of js (must read)

高洛峰
高洛峰Original
2017-02-20 16:48:391142browse

The following editor will bring you an OOP inheritance implementation of js (a must-read article). The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor and take a look.

OOP inheritance implementation of js (must read)

The reason why Student.prototype is created using the create method instead of directly assigning the value of Person.prototype is because if assignment is used If so, both point to the same object. If we want to add a new method to the student class, that won't work. So if you use the create method to use Person.prototype as the prototype of Student.prototype

OOP inheritance implementation of js (must read)

If we modify the attributes on bosn's prototype, then bosn will be affected . It should be noted that we found that if the prototype object of bosn is modified, bosn will not change. For an instance that has already been created, modifying the prototype object will not cause the instance to change.

The above OOP inheritance implementation of js (a must-read article) is all the content shared by the editor. I hope it can give you a reference, and I also hope that everyone will support the PHP Chinese website.

For more related articles on OOP inheritance implementation of js (must-read article), please pay attention to the PHP Chinese website!

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