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
(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.