You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
***The `*` in `yield*`expressions must have a space before and after.**
@@ -1314,7 +1331,7 @@ your code.
1314
1331
;[1, 2, 3].forEach(bar)
1315
1332
```
1316
1333
1317
-
This is much preferred:
1334
+
This is strongly preferred:
1318
1335
1319
1336
```js
1320
1337
var nums = [1, 2, 3]
@@ -1337,44 +1354,42 @@ in JavaScript).
1337
1354
1338
1355
##### Excerpt from *["An Open Letter to JavaScript Leaders Regarding Semicolons"][1]*:
1339
1356
1340
-
[Relying on automatic semicolon insertion] is quite safe, and perfectly valid JS that every browser understands. Closure compiler, yuicompressor, packer, and jsmin all can properly minify it. There is no performance impact anywhere.
1341
-
1342
-
I am sorry that, instead of educating you, the leaders in this language community have given you lies and fear. That was shameful. I recommend learning how statements in JS are actually terminated (and in which cases they are not terminated), so that you can write code that you find beautiful.
1343
-
1344
-
In general, `\n` ends a statement unless:
1345
-
1. The statement has an unclosed paren, array literal, or object literal or ends in some
1346
-
other way that is not a valid way to end a statement. (For instance, ending with `.`
1347
-
or `,`.)
1348
-
2. The line is `--` or `++` (in which case it will decrement/increment the next token.)
1349
-
3. It is a `for()`, `while()`, `do`, `if()`, or `else`, and there is no `{`
1350
-
4. The next line starts with `[`, `(`, `+`, `*`, `/`, `-`, `,`, `.`, or some other
1351
-
binary operator that can only be found between two tokens in a single expression.
1352
-
1353
-
The first is pretty obvious. Even JSLint is ok with `\n` chars in JSON and parenthesized constructs, and with `var` statements that span multiple lines ending in `,`.
1354
-
1355
-
The second is super weird. I’ve never seen a case (outside of these sorts of conversations) where you’d want to do write `i\n++\nj`, but, point of fact, that’s parsed as `i; ++j`, not `i++; j`.
1356
-
1357
-
The third is well understood, if generally despised. `if (x)\ny()` is equivalent to `if (x) { y() }`. The construct doesn’t end until it reaches either a block, or a statement.
1358
-
1359
-
`;` is a valid JavaScript statement, so `if(x);` is equivalent to `if(x){}` or, “If x, do nothing.” This is more commonly applied to loops where the loop check also is the update function. Unusual, but not unheard of.
1360
-
1361
-
The fourth is generally the fud-inducing “oh noes, you need semicolons!” case. But, as it turns out, it’s quite easy to *prefix* those lines with semicolons if you don’t mean them to be continuations of the previous line. For example, instead of this:
1362
-
1363
-
```js
1364
-
foo();
1365
-
[1,2,3].forEach(bar);
1366
-
```
1367
-
1368
-
you could do this:
1369
-
1370
-
```js
1371
-
foo()
1372
-
;[1,2,3].forEach(bar)
1373
-
```
1374
-
1375
-
The advantage is that the prefixes are easier to notice, once you are accustomed to never seeing lines starting with `(` or `[` without semis.
1376
-
1377
-
*End quote from "An Open Letter to JavaScript Leaders Regarding Semicolons".*
1357
+
> [Relying on automatic semicolon insertion] is quite safe, and perfectly valid JS that every browser understands. Closure compiler, yuicompressor, packer, and jsmin all can properly minify it. There is no performance impact anywhere.
1358
+
>
1359
+
> I am sorry that, instead of educating you, the leaders in this language community have given you lies and fear. That was shameful. I recommend learning how statements in JS are actually terminated (and in which cases they are not terminated), so that you can write code that you find beautiful.
1360
+
>
1361
+
> In general, `\n` ends a statement unless:
1362
+
> 1. The statement has an unclosed paren, array literal, or object literal or ends in some
1363
+
> other way that is not a valid way to end a statement. (For instance, ending with `.`
1364
+
> or `,`.)
1365
+
> 2. The line is `--` or `++` (in which case it will decrement/increment the next token.)
1366
+
> 3. It is a `for()`, `while()`, `do`, `if()`, or `else`, and there is no `{`
1367
+
> 4. The next line starts with `[`, `(`, `+`, `*`, `/`, `-`, `,`, `.`, or some other
1368
+
> binary operator that can only be found between two tokens in a single expression.
1369
+
>
1370
+
> The first is pretty obvious. Even JSLint is ok with `\n` chars in JSON and parenthesized constructs, and with `var` statements that span multiple lines ending in `,`.
1371
+
>
1372
+
> The second is super weird. I’ve never seen a case (outside of these sorts of conversations) where you’d want to do write `i\n++\nj`, but, point of fact, that’s parsed as `i; ++j`, not `i++; j`.
1373
+
>
1374
+
> The third is well understood, if generally despised. `if (x)\ny()` is equivalent to `if (x) { y() }`. The construct doesn’t end until it reaches either a block, or a statement.
1375
+
>
1376
+
> `;` is a valid JavaScript statement, so `if(x);` is equivalent to `if(x){}` or, “If x, do nothing.” This is more commonly applied to loops where the loop check also is the update function. Unusual, but not unheard of.
1377
+
>
1378
+
> The fourth is generally the fud-inducing “oh noes, you need semicolons!” case. But, as it turns out, it’s quite easy to *prefix* those lines with semicolons if you don’t mean them to be continuations of the previous line. For example, instead of this:
1379
+
>
1380
+
> ```js
1381
+
>foo();
1382
+
> [1,2,3].forEach(bar);
1383
+
>```
1384
+
>
1385
+
> you could do this:
1386
+
>
1387
+
> ```js
1388
+
>foo()
1389
+
> ;[1,2,3].forEach(bar)
1390
+
>```
1391
+
>
1392
+
> The advantage is that the prefixes are easier to notice, once you are accustomed to never seeing lines starting with `(` or `[` without semis.
0 commit comments