👾 smth
This commit is contained in:
parent
2efe0dce18
commit
293c9b7f47
1 changed files with 2 additions and 3 deletions
|
@ -162,10 +162,8 @@ for (i = 0; i < 3; i++) { // use an existing variable
|
||||||
|
|
||||||
alert(i); // 3, visible, because declared outside of the loop
|
alert(i); // 3, visible, because declared outside of the loop
|
||||||
```
|
```
|
||||||
|
|
||||||
````
|
````
|
||||||
|
|
||||||
|
|
||||||
### Skipping parts
|
### Skipping parts
|
||||||
|
|
||||||
Any part of `for` can be skipped.
|
Any part of `for` can be skipped.
|
||||||
|
@ -286,7 +284,6 @@ if (i > 5) {
|
||||||
|
|
||||||
...and rewrite it using a question mark:
|
...and rewrite it using a question mark:
|
||||||
|
|
||||||
|
|
||||||
```js no-beautify
|
```js no-beautify
|
||||||
(i > 5) ? alert(i) : *!*continue*/!*; // continue isn't allowed here
|
(i > 5) ? alert(i) : *!*continue*/!*; // continue isn't allowed here
|
||||||
```
|
```
|
||||||
|
@ -321,6 +318,7 @@ We need a way to stop the process if the user cancels the input.
|
||||||
The ordinary `break` after `input` would only break the inner loop. That's not sufficient -- labels, come to the rescue!
|
The ordinary `break` after `input` would only break the inner loop. That's not sufficient -- labels, come to the rescue!
|
||||||
|
|
||||||
A *label* is an identifier with a colon before a loop:
|
A *label* is an identifier with a colon before a loop:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
labelName: for (...) {
|
labelName: for (...) {
|
||||||
...
|
...
|
||||||
|
@ -362,6 +360,7 @@ The `continue` directive can also be used with a label. In this case, code execu
|
||||||
Labels do not allow us to jump into an arbitrary place in the code.
|
Labels do not allow us to jump into an arbitrary place in the code.
|
||||||
|
|
||||||
For example, it is impossible to do this:
|
For example, it is impossible to do this:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
break label; // jump to the label below (doesn't work)
|
break label; // jump to the label below (doesn't work)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue