minor
This commit is contained in:
parent
27576c058b
commit
c8a11f3e86
3 changed files with 9 additions and 3 deletions
|
@ -356,7 +356,7 @@ The problem is that JavaScript treats `{...}` in the main code flow (not inside
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
So here JavaScript assumes that we have a code block, that's why there's an error. We have destructuring instead.
|
So here JavaScript assumes that we have a code block, that's why there's an error. We want destructuring instead.
|
||||||
|
|
||||||
To show JavaScript that it's not a code block, we can wrap the expression in parentheses `(...)`:
|
To show JavaScript that it's not a code block, we can wrap the expression in parentheses `(...)`:
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,13 @@ Here's the context stack when we entered the subcall `pow(2, 2)`:
|
||||||
|
|
||||||
The new current execution context is on top (and bold), and previous remembered contexts are below.
|
The new current execution context is on top (and bold), and previous remembered contexts are below.
|
||||||
|
|
||||||
When we finish the subcall -- it is easy to resume the previous context, because it keeps both variables and the exact place of the code where it stopped. Here in the picture we use the word "line", but of course it's more precise.
|
When we finish the subcall -- it is easy to resume the previous context, because it keeps both variables and the exact place of the code where it stopped.
|
||||||
|
|
||||||
|
```smart
|
||||||
|
Here in the picture we use the word "line", as our example there's only one subcall in line, but generally a single line of code may contain multiple subcalls, like `pow(…) + pow(…) + somethingElse(…)`.
|
||||||
|
|
||||||
|
So it would be more precise to say that the execution resumes "immediately after the subcall".
|
||||||
|
```
|
||||||
|
|
||||||
### pow(2, 1)
|
### pow(2, 1)
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ What `class User {...}` construct really does is:
|
||||||
1. Creates a function named `User`, that becomes the result of the class declaration. The function code is taken from the `constructor` method (assumed empty if we don't write such method).
|
1. Creates a function named `User`, that becomes the result of the class declaration. The function code is taken from the `constructor` method (assumed empty if we don't write such method).
|
||||||
2. Stores class methods, such as `sayHi`, in `User.prototype`.
|
2. Stores class methods, such as `sayHi`, in `User.prototype`.
|
||||||
|
|
||||||
Afterwards, for `new User` objects, when we call a method, it's taken from the prototype, just as described in the chapter <info:function-prototype>. So the object has access to class methods.
|
After `new User` object is created, when we call its method, it's taken from the prototype, just as described in the chapter <info:function-prototype>. So the object has access to class methods.
|
||||||
|
|
||||||
We can illustrate the result of `class User` declaration as:
|
We can illustrate the result of `class User` declaration as:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue