javascript - When should I use a semicolon after curly braces? -


many times i've seen semicolon used after function declaration, or after anonymous "return" function of module pattern script. when appropriate use semicolon after curly braces?

you use semi-colon after statement. statement:

var foo = function() {   alert("bar"); }; 

because variable assignment (ie creating , assigning anonymous function variable).

the 2 things spring mind aren't statements function declarations:

function foo() {   alert("bar"); } 

and blocks:

{   alert("foo"); } 

note: same block construct without semi-colon applies for, do , while loops.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -