Strings longer than 80 characters should be written across multiple lines using string concatenation.

Note: If overused, long strings with concatenation could impact performance. jsPerf & Discussion

// badvar errorMessage ='This is a super long error that was thrown because of Batman. When you stop to think about how Batman had anything to do with this, you would get nowhere fast.';
// badvar errorMessage ='This is a super long error that \was thrown because of Batman. \When you stop to think about \how Batman had anything to do \with this, you would get nowhere \fast.';
// goodvar errorMessage ='This is a super long error that '+'was thrown because of Batman. '+'When you stop to think about '+'how Batman had anything to do '+'with this, you would get nowhere '+'fast.';

When programatically building up a string, use Array#join instead of string concatenation. Mostly for IE: jsPerf.

Never declare a function in a non-function block (if, while, etc). Assign the function to a variable instead. Browsers will allow you to do it, but they all interpret it differently, which is bad news bears.

Named function expressions hoist the variable name, not the function name or the function body.

functionexample() {
console.log(named); // => undefinednamed(); // => TypeError named is not a functionsuperPower(); // => ReferenceError superPower is not definedvarnamed=functionsuperPower() {
console.log('Flying');
};
}
// the same is true when the function name// is the same as the variable name.functionexample() {
console.log(named); // => undefinednamed(); // => TypeError named is not a functionvarnamed=functionnamed() {
console.log('named');
}
}

Prefixing your comments with FIXME or TODO helps other developers quickly understand if you're pointing out a problem that needs to be revisited, or if you're suggesting a solution to the problem that needs to be implemented. These are different than regular comments because they are actionable. The actions are FIXME -- need to figure this out or TODO -- need to implement.