Home >Web Front-end >JS Tutorial >JavaScript object-oriented shared member attributes and methods and prototype keyword usage_javascript skills

JavaScript object-oriented shared member attributes and methods and prototype keyword usage_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:20:241276browse

The examples in this article describe the shared member properties and methods of JavaScript object-oriented and the usage of prototype keyword. Share it with everyone for your reference. The details are as follows:

To share member properties and methods, use the prototype keyword

Copy code The code is as follows:

Pay attention to the knowledge points:

(1) Using this. attribute name or method name, you can also share them with the instantiated object, but they are stored in different spaces (stack areas). In this case, each object has exclusive code. If there are many objects, the efficiency will become lower;
(2) If prototype is used, it is stored in the same stack area, that is, multiple objects share code. When one of the objects is changed, the other objects are not affected.

I hope this article will be helpful to everyone’s JavaScript programming design.

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