Skip to content

Commit

Permalink
Fix typos (mdn#30467)
Browse files Browse the repository at this point in the history
prototypical -> prototypal
  • Loading branch information
hugo-astier authored Nov 23, 2023
1 parent ac7f942 commit 39b6b6c
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ page-type: guide

In programming, _inheritance_ refers to passing down characteristics from a parent to a child so that a new piece of code can reuse and build upon the features of an existing one. JavaScript implements inheritance by using [objects](/en-US/docs/Web/JavaScript/Data_structures#objects). Each object has an internal link to another object called its _prototype_. That prototype object has a prototype of its own, and so on until an object is reached with `null` as its prototype. By definition, `null` has no prototype and acts as the final link in this **prototype chain**. It is possible to mutate any member of the prototype chain or even swap out the prototype at runtime, so concepts like [static dispatching](https://en.wikipedia.org/wiki/Static_dispatch) do not exist in JavaScript.

JavaScript is a bit confusing for developers experienced in class-based languages (like Java or C++), as it is [dynamic](/en-US/docs/Web/JavaScript/Data_structures#dynamic_and_weak_typing) and does not have static types. While this confusion is often considered to be one of JavaScript's weaknesses, the prototypical inheritance model itself is, in fact, more powerful than the classic model. It is, for example, fairly trivial to build a classic model on top of a prototypical model — which is how [classes](/en-US/docs/Web/JavaScript/Reference/Classes) are implemented.
JavaScript is a bit confusing for developers experienced in class-based languages (like Java or C++), as it is [dynamic](/en-US/docs/Web/JavaScript/Data_structures#dynamic_and_weak_typing) and does not have static types. While this confusion is often considered to be one of JavaScript's weaknesses, the prototypal inheritance model itself is, in fact, more powerful than the classic model. It is, for example, fairly trivial to build a classic model on top of a prototypal model — which is how [classes](/en-US/docs/Web/JavaScript/Reference/Classes) are implemented.

Although classes are now widely adopted and have become a new paradigm in JavaScript, classes do not bring a new inheritance pattern. While classes abstract most of the prototypical mechanism away, understanding how prototypes work under the hood is still useful.
Although classes are now widely adopted and have become a new paradigm in JavaScript, classes do not bring a new inheritance pattern. While classes abstract most of the prototypal mechanism away, understanding how prototypes work under the hood is still useful.

## Inheritance with the prototype chain

Expand Down Expand Up @@ -640,7 +640,7 @@ const filledRectangle = new FilledRectangle(5, 10, "blue");
<td>
Supported in all modern engines. Very high readability and maintainability.
<a href="/en-US/docs/Web/JavaScript/Reference/Classes/Private_properties">Private properties</a>
are a feature with no trivial replacement in prototypical inheritance.
are a feature with no trivial replacement in prototypal inheritance.
</td>
</tr>
<tr>
Expand Down

0 comments on commit 39b6b6c

Please sign in to comment.