Skip to content

Instantly share code, notes, and snippets.

@tsouk
Created January 10, 2012 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsouk/1589651 to your computer and use it in GitHub Desktop.
Save tsouk/1589651 to your computer and use it in GitHub Desktop.
JavaScript Blunders
// 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