Introduction to Object Prototypes
All objects in JavaScript have an internal property called the prototype. Prototypes are used in JavaScript to reuse code and combine objects. This section will help you understand how prototype object chains allow objects to inherit features from one another. It will also explain how the prototype property is used to add methods to constructors.
Object prototypes
Prototypes are the mechanism by which
JavaScript objects inherit features from one another. In this article,
we explain what a prototype is, how prototype chains work, and how a
prototype for an object can be set.
Prerequisites: | Understanding JavaScript functions, familiarity with JavaScript basics (see First steps and Building blocks), and OOJS basics (see Introduction to objects). |
---|---|
Objective: | To understand JavaScript object prototypes, how prototype chains work, and how to set the prototype of an object. |
Source: Mozilla, https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object_prototypes
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.