remove cut
This commit is contained in:
parent
37f1936622
commit
be007e78ef
99 changed files with 0 additions and 198 deletions
|
@ -5,8 +5,6 @@ As we know, objects can store properties.
|
|||
|
||||
Till now, a property was a simple "key-value" pair to us. But an object property is actually more complex and tunable thing.
|
||||
|
||||
[cut]
|
||||
|
||||
## Property flags
|
||||
|
||||
Object properties, besides a **`value`**, have three special attributes (so-called "flags"):
|
||||
|
|
|
@ -7,8 +7,6 @@ The first kind is *data properties*. We already know how to work with them. Actu
|
|||
|
||||
The second type of properties is something new. It's *accessor properties*. They are essentially functions that work on getting and setting a value, but look like regular properties to an external code.
|
||||
|
||||
[cut]
|
||||
|
||||
## Getters and setters
|
||||
|
||||
Accessor properties are represented by "getter" and "setter" methods. In an object literal they are denoted by `get` and `set`:
|
||||
|
|
|
@ -6,8 +6,6 @@ For instance, we have a `user` object with its properties and methods, and want
|
|||
|
||||
*Prototypal inheritance* is a language feature that helps in that.
|
||||
|
||||
[cut]
|
||||
|
||||
## [[Prototype]]
|
||||
|
||||
In JavaScript, objects have a special hidden property `[[Prototype]]` (as named in the specification), that is either `null` or references another object. That object is called "a prototype":
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
In modern JavaScript we can set a prototype using `__proto__`, as described in the previous article. But it wasn't like that all the time.
|
||||
|
||||
[cut]
|
||||
|
||||
JavaScript has had prototypal inheritance from the beginning. It was one of the core features of the language.
|
||||
|
||||
But in the old times, there was another (and the only) way to set it: to use a `"prototype"` property of the constructor function. And there are still many scripts that use it.
|
||||
|
|
|
@ -9,8 +9,6 @@ There are also other ways to get/set a prototype, besides those that we already
|
|||
- [Object.getPrototypeOf(obj)](mdn:js/Object.getPrototypeOf) -- returns the `[[Prototype]]` of `obj`.
|
||||
- [Object.setPrototypeOf(obj, proto)](mdn:js/Object.setPrototypeOf) -- sets the `[[Prototype]]` of `obj` to `proto`.
|
||||
|
||||
[cut]
|
||||
|
||||
For instance:
|
||||
|
||||
```js run
|
||||
|
|
|
@ -11,8 +11,6 @@ In JavaScript there are several well-known programming patterns to make classes
|
|||
|
||||
The `class` construct will be described in the next chapter, but in JavaScript it's a "syntax sugar" and an extension of one of the patterns that we'll study here.
|
||||
|
||||
[cut]
|
||||
|
||||
|
||||
## Functional class pattern
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
The "class" construct allows to define prototype-based classes with a clean, nice-looking syntax.
|
||||
|
||||
[cut]
|
||||
|
||||
## The "class" syntax
|
||||
|
||||
The `class` syntax is versatile, we'll start with a simple example first.
|
||||
|
|
|
@ -5,8 +5,6 @@ Classes can extend one another. There's a nice syntax, technically based on the
|
|||
|
||||
To inherit from another class, we should specify `"extends"` and the parent class before the brackets `{..}`.
|
||||
|
||||
[cut]
|
||||
|
||||
Here `Rabbit` inherits from `Animal`:
|
||||
|
||||
```js run
|
||||
|
|
|
@ -4,8 +4,6 @@ The `instanceof` operator allows to check whether an object belongs to a certain
|
|||
|
||||
Such a check may be necessary in many cases, here we'll use it for building a *polymorphic* function, the one that treats arguments differently depending on their type.
|
||||
|
||||
[cut]
|
||||
|
||||
## The instanceof operator [#ref-instanceof]
|
||||
|
||||
The syntax is:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue