Possible Duplicate:
What are the rules for Javascript's automatic semicolon insertion?
I know you can chain js (or jquery) on differnt lines like so:
$('div')
.filter(':first').hide().end()
.find('span').css('opacity', .5)
...;
And the engine doesn’t put semicolons in which would break it. On the other hand if I do this:
return
i ? 1 : 2
It puts a semicolon in and always return undefined. What are the guidelines for when it does what?
In your first example, the subsequent lines are invalid syntax when used alone.
In your second example, the second line is a valid (though useless) statement.
For more precise rules, see the spec, which goes on for three pages.