JavaScript Cheat Sheet by DaveChild
cheatography.com/davechild/cheat-sheets/javascript
By October 19, 2011
DaveChild
Regular Expressions JavaScript Event JavaScript Dates
Syntax Handlers
Date() setMonth()
^ Start of onabort onmous‐
string edown
getDate() setFul‐
lYear()
$ End of string onblur onmous‐
emove
getDay() setHours()
. Any single
character onchange onmouseout
getMonth setMin‐
utes()
(a|b) a or b onclick onmous‐
eover
getFullYear setSec‐
(...) Group onds()
section ondblclick onmouseup
getYear setMillis‐
[abc] In range (a, ondragdrop onmove econds()
b or c)
onerror onreset getHours setTime()
[^abc] Not in range
onfocus onresize getMinutes setUTC‐
\s White space Date()
onkeydown onselect
a? Zero or one getSeconds setUTC‐
of a Day()
onkeypress onsubmit
a* Zero or getMillis‐ setUTC‐
more of a onkeyup onunload econds Month()
a*? Zero or onload getTime setUTC‐
more, FullYear()
ungreedy
JavaScript Arrays
1/7
a+ One or more concat() slice() getTimezo‐ setUTC‐
of a neOffset() Hours()
join() sort()
a+? One or getUTC‐ setUTC‐
more, Date() Minutes()
ungreedy length splice()
getUTC‐ setUTC‐
a{3} Exactly 3 of pop() toSource() Day() Seconds()
a
push() toString() getUTC‐ setUTC‐
a{3,} 3 or more of Month() Milliseco‐
a nds()
reverse() unshift()
getUTCFul‐ toSource()
a{,6} Up to 6 of a shift() valueOf() lYear()
a{3,6} 3 to 6 of a
JavaScript Numbers getUTC‐ toString()
Hours()
and Maths
a{3,6}? 3 to 6 of a,
ungreedy
abs() min() getUTC‐ toGMTS‐
Minutes() tring()
\ Escape
character acos() NEGATI‐
VE_INF‐ getUTC‐ toUTCS‐
INITY Seconds() tring()
[:punct:] Any punctu‐
ation symbol
asin() PI getUTCMil‐ toLocaleS‐
liseconds() tring()
[:space:] Any space
character atan() POSITI‐
VE_INF‐ parse() UTC()
INITY
[:blank:] Space or
setDate() valueOf()
tab
atan2() pow()
There's an excellent JavaScript Strings
ceil() random()
regular expression tester
at: http://regexpal.com/ charAt() slice()
Pattern Modifiers cos() round()
charCo‐ split() x
g Global match E sin() deAt()
2/7
i* Case-insensitive exp() sqrt() concat() substr()
floor() SQRT1_2 fromCh‐ substring()
m* Multiple lines
arCode()
LN10 SQRT2
s* Treat string as
single line indexOf() toLowe‐
rCase()
LN2 tan()
x* Allow comments
and whitespace lastIn‐ toUppe‐
log() toSource()
in pattern dexOf() rCase()
LOG10E toExpo‐
e* Evaluate replac‐ length toLocaleL‐
nential()
ement owerCase()
LOG2E toFixed()
U* Ungreedy pattern locale‐ toLocaleU‐
Com‐ pperCase()
max() toPrec‐ pare()
* PCRE modifier ision()
match() x toSource()
JavaScript RegExp
MAX_VALUE toString()
Object
replace() valueOf()
MIN_VALUE valueOf() x
compile() lastParen
NaN search() x
exec() leftCO‐
ntext
String object methods with
JavaScript Booleans
global multiline an x support regular
expressions.
toSource() valueOf()
ignoreCase rightC‐ JavaScript Functions
ontext
toString()
decode‐ isNaN()
input source URI()
lastIndex test() decode‐ Number()
URICom‐
ponent()
lastMatch
3/7
encode‐ parseF‐
URI() loat()
encode‐ parseInt()
URICom‐
ponent()
escape() String()
eval() unescape()
isFinite()
How's Your Readability?
Cheatography is sponsored by Readable.com. Check out Readable to make your content
and copy more engaging and support Cheatography!
Measure Your Readability Now!
Help Us Go Positive!
We offset our carbon usage with Ecologi. Click the link below to help us!
Download the JavaScript Cheat Sheet
4/7
5/7
2 Pages
Comments
Piotrek 20:16 28 Feb 12
Where's typof() ?
pdf isjunk 15:22 6 Aug 12
When you hit the PDF button, it chops off the bottom of the page and has a second page
with your face and half of the credits on it. comical fail. Thought you should know.
Murali Prashanth N 08:42 16 Feb 13
Thnx...dave
?????????????? 08:43 16 Feb 13
Wheres alert() and prompt()?
Dave Lampton 17:16 26 Mar 13
The event handlers should be all lowercase.
santsoh suryawanshi 17:44 17 Feb 14
these PDF make easy to create web site ,present and validate as well.
there is no need to open any book or google for any tag.
Thnk you dave.
Er1c Nevertells 19:45 31 Oct 14
This is a messed up ripoff of other quality quick references, with your mug slapped in it and
a shameless plug to your site.
DaveChild, 19:47 31 Oct 14
I published the first version of this cheat sheet on ILoveJackDaniels.com in 2005. I don't
think there were many others around then, if any. It's been through a few changes in that
time, of course, but it's basically the same.
6/7
James 17:35 19 Oct 15
Thanks Dave, with all the criticism and few thanks its a wonder people try to help each
other. Good work.
pppandit 17:35 19 Oct 15
very good
Michael Pohoreski 16:09 16 Sep 16
Good starting point but still has a few errors (as of Jan 2016) :-/
1. Dates are not alphabetized. i.e. getYear, getSeconds, are out of order
2. Dates functions are missing parenthesis. i.e. getYear()
3. Missing Date.now()
elbeji, 15:43 7 Dec 20
thanks a lot
Add a Comment
Your Comment
Related Cheat Sheets
CoffeeScript Cheat Sheet
jQuery Cheat Sheet
JavaScript Cheat Sheet
More Cheat Sheets by DaveChild
Regular Expressions Cheat Sheet
Linux Command Line Cheat Sheet
CSS2 Cheat Sheet
7/7