Skip to content

Commit

Permalink
Move extends reference into its own page (mdn#23305)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Jan 3, 2023
1 parent 25582b9 commit e859bb7
Show file tree
Hide file tree
Showing 8 changed files with 254 additions and 238 deletions.
2 changes: 1 addition & 1 deletion files/en-us/web/javascript/guide/using_classes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ class ColorWithAlpha extends Color {
}
```

A class can only extend from one class. This prevents problems in multiple inheritance like the [diamond problem](https://en.wikipedia.org/wiki/Multiple_inheritance#The_diamond_problem). However, due to the dynamic nature of JavaScript, it's still possible to achieve the effect of multiple inheritance through class composition and [mixins](/en-US/docs/Web/JavaScript/Reference/Classes#mix-ins).
A class can only extend from one class. This prevents problems in multiple inheritance like the [diamond problem](https://en.wikipedia.org/wiki/Multiple_inheritance#The_diamond_problem). However, due to the dynamic nature of JavaScript, it's still possible to achieve the effect of multiple inheritance through class composition and [mixins](/en-US/docs/Web/JavaScript/Reference/Classes/extends#mix-ins).

Instances of derived classes are also [instances of](/en-US/docs/Web/JavaScript/Reference/Operators/instanceof) the base class.

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/javascript/language_overview/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ const p = new Person("Maria");
console.log(p.sayHello());
```

JavaScript classes are just functions that must be instantiated with the [`new`](/en-US/docs/Web/JavaScript/Reference/Operators/new) operator. Every time a class is instantiated, it returns an object containing the methods and properties that the class specified. Classes don't enforce any code organization — for example, you can have functions returning classes, or you can have multiple classes per file. Here's an example of how ad hoc the creation of a class can be: it's just an expression returned from an arrow function. This pattern is called a [mixin](/en-US/docs/Web/JavaScript/Reference/Classes#mix-ins).
JavaScript classes are just functions that must be instantiated with the [`new`](/en-US/docs/Web/JavaScript/Reference/Operators/new) operator. Every time a class is instantiated, it returns an object containing the methods and properties that the class specified. Classes don't enforce any code organization — for example, you can have functions returning classes, or you can have multiple classes per file. Here's an example of how ad hoc the creation of a class can be: it's just an expression returned from an arrow function. This pattern is called a [mixin](/en-US/docs/Web/JavaScript/Reference/Classes/extends#mix-ins).

```js
const withAuthentication = (cls) =>
Expand Down
191 changes: 164 additions & 27 deletions files/en-us/web/javascript/reference/classes/extends/index.md

Large diffs are not rendered by default.

Loading

0 comments on commit e859bb7

Please sign in to comment.