You use a semicolon after a statement. This is a statement:
var foo = function() {
alert("bar");
};
because it is a variable assignment (i.e. creating and assigning an anonymous function to a variable).
The two things that spring to mind that aren’t statements are function declarations:
function foo() {
alert("bar");
}
and blocks:
{
alert("foo");
}
Note: that same block construct without semi-colon also applies to for
, do
and while
loops.