Without semicolons, it will evaluate:
(function() { alert('first'); }())(function() { alert('second'); }())
The first function is executed, and since it returns nothing, it additionally evaluates:
undefined(function() { alert('second'); }())
Then the second function is executed, and it returns undefined again, therefore:
undefined(undefined)
Which doesn't work, of course ( TypeError , since undefined not a function). Separate function calls must be separated by a semicolon, since each statement must be valid.
source share