4.2.1 Array literals: optionally block-like
Any array literal may optionally be formatted as if it were a “block-likeconstruct.” For example, the following are all valid (not an exhaustivelist):
someMethod(foo, [
0, 1, 2,
], bar);
Other combinations are allowed, particularly when emphasizing semantic groupingsbetween elements, but should not be used only to reduce the vertical size oflarger arrays.
4.2.2 Object literals: optionally block-like
Any object literal may optionally be formatted as if it were a “block-likeconstruct.” The same examples apply as . Forexample, the following are all valid (not an exhaustive list):
const c = {a: 0, b: 1};
a: 0, b: 1,
}, bar);
4.2.3 Class literals
Example:
foo.Bar = class extends Foo {
/** @override */
method() {
return super.method() / 2;
}
};
/** @interface */
class Frobnicator {
frobnicate(message) {}
4.2.4 Function expressions
When declaring an anonymous function in the list of arguments for a functioncall, the body of the function is indented two spaces more than the precedingindentation depth.
Example:
4.2.5 Switch statements
After a switch label, a newline appears, and the indentation level is increased+2, exactly as if a block were being opened. An explicit block may be used ifrequired by lexical scoping. The following switch label returns to the previousindentation level, as if a block had been closed.
A blank line is optional between a break
and the following case.
Example:
switch (animal) {
case Animal.BANDERSNATCH:
handleBandersnatch();
break;
case Animal.JABBERWOCK:
handleJabberwock();
break;
default:
}