There are some rules for ASI (automated semicolon insertion). If you start a line with a bracket (or a regex) ASI will not tread them as a new statement.
To do so, you have to place a semicolon in front of the statement (same line or the line before).
If you would like to omit all semicolons (like me), you can also use void:
void [1,2,4].forEach(console.log)