Hacker News new | ask | show | jobs
by insin 5234 days ago
You could use anything which separates statements or ensures the function is treated as an expression. Two examples which are more in keeping with the intended use of the operators in question:

  ;function() {
    // Some initialization.
  }()

  void function() {
    // Some initialization.
  }()
1 comments

So now we've gone a) from semicolon consistently after statements, to having to remember where to prefix with semicolons, or b) from one character to four.

Why aren't we just using the semicolon as it is required in any other (C-based) language?

JS's syntax is influenced by C via its pretensions of being somehow related to Java, but I think it's a stretch to call it a "C-based language".