-
-
Save knarf-se/1031626 to your computer and use it in GitHub Desktop.
When using semicolons in JavaScript matters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This fails in firefox, chrome, and maybe others. | |
// Add a semicolon after foo() and to eliminate the error. | |
function foo() { /* code goes here */ } | |
foo() // no semi-colon here | |
(function() { /* anonymouse function */ })() // bork! | |
//You can also write the closure like this instead of putting a semicolon after foo: | |
//!function() { /* anonymouse function */ }() // bork! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment