Created
January 10, 2012 15:37
-
-
Save tsouk/1589651 to your computer and use it in GitHub Desktop.
JavaScript Blunders
This file contains hidden or 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
// Oh what a tangled web we stare, when first we practice to declare | |
// ---------------------------------------------------------------- | |
// When var statement become longer than a page, there are some problems | |
var a, | |
b, | |
c, <- take this line out and the rest vars are now global | |
d, | |
e; | |
var a, | |
b, | |
c, | |
d, | |
e; <- take this line out and IE will not like the trailing comma. | |
// Evaluations | |
( statement1 ) && ( statement2 ) && ( statement3 ); // Will stop evaluating at the first false statement | |
( statement1 ) || ( statement2 ) || ( statement3 ); // Will stop evaluating at the first true statement | |
// Function declarations and function expressions. | |
alert(name2); // undefined | |
name1 = function name2() { | |
alert(name2); // function? | |
} | |
alert(name2); // undefined | |
alert(name2); // function? | |
function name2() { | |
alert(name2); // function? | |
} | |
alert(name2); // function? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment