Non-standard language extensions such as expression closures or let expressions should be avoided, since they make code harder to read or reuse.

Use standard language features instead. For instance, expression closures can be replaced by ECMAScript 2015 arrow functions, or alternatively by plain functions; let statements and expressions can be replaced by ECMAScript 2015 let declarations; and for each ... in statements can be replaced by ECMAScript 2015 for ... of statements.

The following example uses an expression closure with map:

The equivalent code using an ECMAScript 2015 arrow function is as follows:

On ECMAScript 2015 platforms, a plain function can be used instead:

As another example, consider this use of a let statement:

It can easily be replaced by a block-scoped let declaration:

Older versions of Firefox support a postfix notation for array comprehensions:

This notation should be converted into the semantically equivalent prefix notation supported by newer browsers:

  • Mozilla Developer Network: Arrow functions.
  • Mozilla Developer Network: Non-standard let extensions.
  • Mozilla Developer Network: for each...in.