See the Pen thecodelog.com - JS Grammar 1 by Deano (@deangilewicz) on CodePen.
A statement-series comma operator allows you to string together multiple standalone expression statements into a single statement.
See the Pen thecodelog.com - JS Grammar 2 by Deano (@deangilewicz) on CodePen.
Curly braces are used for object literals. Below, the property:value pair gets assigned to the variable obj, and thing is a label for the statement myFn().
See the Pen thecodelog.com - JS Grammar 3 by Deano (@deangilewicz) on CodePen.
Curly braces are also used for blocks. Blocks don’t need semicolons to terminate them.
See the Pen thecodelog.com - JS Grammar 4 by Deano (@deangilewicz) on CodePen.
If and else statements are allowed to omit the { } around their attached block if they only contain a single statement.
See the Pen thecodelog.com - JS Grammar 5 by Deano (@deangilewicz) on CodePen.
Automatic semicolon insertion (ASI) occurs when the JavaScript engine assumes a semicolon should be in certain places in your program even if you didn’t put one there. ASI will only take effect in the presence of a newline (line break). Semicolons are not inserted in the middle of a line.
See the Pen thecodelog.com - JS Grammar 6 by Deano (@deangilewicz) on CodePen.
The following variable names can be used in any combination:
See the Pen thecodelog.com - JS Grammar 7 by Deano (@deangilewicz) on CodePen.
However, variable names cannot start with a number and cannot be a reserved word.
The use of strict mode ‘use strict’ helps identify errors earlier in code.
See the Pen thecodelog.com - JS Grammar 8 by Deano (@deangilewicz) on CodePen.
When using a try – catch, try only requires either catch or finally, though both can be present.
See the Pen thecodelog.com - JS Grammar 9 by Deano (@deangilewicz) on CodePen.
‘return 42’ runs right away, which sets up the completion value from the myFn() call. This action completes the try clause and the finally clause immediately runs next. Only then is the myFn() function complete, so that its completion value is returned back for the console.log(..) statement to use.
The exact same behavior is true of a throw inside of a try block:
See the Pen thecodelog.com - JS Grammar 10 by Deano (@deangilewicz) on CodePen.
Omitting a return in a finally block lets the previous return stand:
See the Pen thecodelog.com - JS Grammar 11 by Deano (@deangilewicz) on CodePen.