minor
This commit is contained in:
parent
28a514a0d7
commit
cdf6156088
4 changed files with 6 additions and 7 deletions
|
@ -309,8 +309,7 @@ for (let i = 0; i < 3; i++) {
|
|||
|
||||
let input = prompt(`Value at coords (${i},${j})`, '');
|
||||
|
||||
// what if I want to exit from here to Done (below)?
|
||||
|
||||
// what if we want to exit from here to Done (below)?
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
By specification, object property keys may be either of string type, or of symbol type. Not numbers, not booleans, only strings or symbols, these two types.
|
||||
|
||||
Till now we've only seen strings. Now let's see the advantages that symbols can give us.
|
||||
Till now we've been using only strings. Now let's see the benefits that symbols can give us.
|
||||
|
||||
## Symbols
|
||||
|
||||
"Symbol" value represents a unique identifier.
|
||||
A "symbol" represents a unique identifier.
|
||||
|
||||
A value of this type can be created using `Symbol()`:
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
In JavaScript we can only inherit from a single object. There can be only one `[[Prototype]]` for an object. And a class may extend only one other class.
|
||||
|
||||
But sometimes that feels limiting. For instance, I have a class `StreetSweeper` and a class `Bicycle`, and want to make their mix: a `StreetSweepingBicycle`.
|
||||
But sometimes that feels limiting. For instance, we have a class `StreetSweeper` and a class `Bicycle`, and want to make their mix: a `StreetSweepingBicycle`.
|
||||
|
||||
Or we have a class `User` and a class `EventEmitter` that implements event generation, and we'd like to add the functionality of `EventEmitter` to `User`, so that our users can emit events.
|
||||
|
||||
There's a concept that can help here, called "mixins".
|
||||
|
||||
As defined in Wikipedia, a [mixin](https://en.wikipedia.org/wiki/Mixin) is a class that contains methods for use by other classes without having to be the parent class of those other classes.
|
||||
As defined in Wikipedia, a [mixin](https://en.wikipedia.org/wiki/Mixin) is a class containing methods that can be used by other classes without a need to inherit from it.
|
||||
|
||||
In other words, a *mixin* provides methods that implement a certain behavior, but we do not use it alone, we use it to add the behavior to other classes.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue