Javascript Cheatsheet

Table of contents
Global
Any object
Array
Boolean
Date
Function
Math
Number
Object
RegExp
String
XMLHttpRequest
About

Global

Properties
Infinity
NaN
undefined
Methods
eval(string [, object])
isFinite(number)
isNaN(number)
parseFloat(string)
parseInt(string)
encodeURI(string)
decodeURI(string)
encodeURIComponent(string)
decodeURIComponent(string)

Any object

Properties
constructor
prototype
Methods
toSource()
toString()
valueOf()

Array

Constructors
new Array(length)
new Array(el0, el1, ...)
[el0, el1, ...]
Properties
length
Methods (mutators)
pop()
push(el0, el1, ...)
reverse()
shift()
splice(index, count [, el0, el1, ...])
unshift()
Methods (accessors)
concat(add0, add1, ...)
join(separator)
slice(begin [, end])

Boolean

Constructors
new Boolean(value)

Date

Constructors
new Date(milliseconds)
new Date(string)
new Date(yr_num, mo_num, day_num [, hr_num, min_num, sec_num, ms_num])
Methods (static)
Date.now()
Date.parse(string)
Date.UTC(yr_num, mo_num [, day_num hr_num, min_num, sec_num, ms_num])
Methods
getDate()
getDay()
getFullYear()
getMilliseconds()
getMinutes()
getMonth() // zero-based
getSeconds()
getTime()
getTimezoneOffset()
setDate(month_day)
setFullYear(year)
setMilliseconds( millisec )
setMinutes(minutes)
setMonth(month) // zero-based
setSeconds(seconds)
setTime(timestamp)
Operators
date1 - date2 // time in milliseconds
More
Date object reference

Function

Constructors
new Function([arg1, ...,] function_body)
Properties
length
Methods
apply(this_arg [, arguments])
call(this_arg [, arg1, ...])

Math

Properties
E // Euler's constant, ~ 2.718
LN2 // Natural logarithm of 2, ~ 0.693.
LN10 // Natural logarithm of 10, ~ 2.302
LOG2E // Base 2 logarithm of E, ~ 1.442
LOG10E // Base 10 logarithm of E, ~ 0.434
PI // ~ 3.14159
SQRT1_2 // sqrt(1/2) or 1/sqrt(2), ~ 0.707
SQRT2: Square root of 2, ~ 1.414
Methods (static)
abs(number)
acos(number) // Return radians
asin(number) // Return radians
atan(number) // Return radians
atan2(number) // Return radians
ceil(number)
exp(number)
floor(number)
log(number)
max([n1, n2, ...])
min([n1, n2, ...])
pow(base, exponent)
random()
round(number)
sin(number)
sqrt(number)
tan(number) // Take radians

Number

Constructors
new Number(value)
number
Properties
MAX_VALUE
MIN_VALUE
NaN
NEGATIVE_INFINITY
POSITIVE_INFINITY
Methods
toExponential( [fraction_digits] )
toFixed([digits])
toLocaleString()
toPrecision([precision])

Object

Constructors
new Object()
{[property: value, ...]}

RegExp

Constructors
new RegExp(pattern [, flags])
/pattern/flags
Properties
global
ignoreCase
lastIndex
multiline
source
Methods
exec(string): {index: number, input: string, 0: matched, 1: paran1, ...}
test(string)

String

Constructors
new String(string)
"string"
Properties
length
Methods (static)
String.fromCharCode( array )
Methods
charAt(index)
charCodeAt(index)
concat(string1, ...)
indexOf(string [, fromIndex]) // -1 on failure
lastIndexOf(string [, fromIndex]) // -1 on failure
match(regexp)
replace(regexp|substr, new_substr|function)
search(regexp) // -1 on failure
slice(start [, end])
split(by_string [, limit])
substr(start [, length])
substring(start [, end])
toLowerCase()
toUpperCase()
More
String object reference

XMLHttpRequest

Constructors
new XMLHttpRequest()
Properties
onerror
onload
onprogress
onreadystatechange
readyState
responseText
responseXML
status
Methods
open(method, URL, synchronous)
send(data)
overrideMimeType(data)
setRequestHeader(header, value)
getResponseHeader(header)
send(data)
Progress event properties
position
totalSize

About

Author
Felix Pleşoianu
License
Creative Commons: Attribution-Sharealike v2.5
Credits
Mozilla Developer Center