Also see my Node.js Cheatsheet.
- ECMAScript Language Specification, 3rd edition (PDF)
- Mozilla Developer Network
- Array, Boolean, Date, Error, Function, Math, Number, Object, RegExp, String
- Douglas Crockford: Code Conventions, Private Members
- jQuery Docs, Getting Started with jQuery, Quick and Dirty Guide to QUnit
- Microsoft Ajax Library Client Reference
- DOM Level 1
- DOM Level 2 Core, DOM Level 2 Events, DOM Level 2 HTML
- DOM Level 3 Core, DOM Level 3 XPath
- Gecko DOM Reference
- Geolocation API Specification
Generally, use === and !== rather than == and != (which coerce arguments before comparison).
Numeric values are really IEEE floating-point, even when they look like integers.
NaN is not equal to itself. Use isNaN()
Semicolons are often optional, but interpreter may insert semicolons in unexpected places, so it is best to use semicolons and to put opening braces on the same line as the keyword.
var declaration is missing, then a variable is global. The scope of a
var is the entire function in which it is declared (blocks do not create a new scope)
Note difference between
substr(startIndex, charCount) and
Avoid using / / style comments, as regular expressions can contain similar character sequences.
Special Values and Constants
null, undefined, false, true, NaN, Infinity
Values that are considered to be "false" in conditionals: undefined, null, false, '', 0, NaN
typeof obj returns one of these values: 'undefined', 'object', 'boolean', 'number', 'string', 'function'. If the operand is an array or null, then the result is 'object'. If the operand is a regexp, the result may be either 'object' or 'function'.
- array.slice(start, end)
- array.splice(start, deleteCount, item...)
- function.apply(thisArg, argArray)
- string.indexOf(searchString, position)
- string.lastIndexOf(searchString, position)
- string.replace(searchValue, replaceValue)
- string.slice(start, end)
- string.split(separator, limit)
- string.substring(start, end)