Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Example when a semicolon is required in non-minimized javascript.

    alert(1) // add semi-colon here to make this code work
    (function(){alert(2)})()


There are other options here too but, given the OP, people seem to get irate when you use the features the language specification guarantees :'/

  alert(1)
  void function(){alert(2)}()


Nice, didn't know void can be prepended to a function definition.


Someone should write a tool that automatically inserts that comment instead of a semicolon. LOL




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: