Hacker News new | ask | show | jobs
by senorerik 3080 days ago
As long as we're writing bad code, here's my stab at the code golf version:

  i=0,a={valueOf:_=>++i}
- Omitting the variable statements in non-strict mode creates global (function scoped) variables

- The comma operator evaluates its operands left to right and returns the rightmost operand, the result of which is irrelevant in this case

- The arrow function allows us to omit parenthesis around the function parameters, so any single character variable name works (in this case _)

- The arrow function syntax also allows us to omit the curly braces, and will automatically return the body of the function.

- Automatic Semicolon Injection allows us to omit the trailing ;