Show Menu

JavaScript Cheat Sheet by DaveChild

JavaScript methods and functions, a guide to regular expressions and the XMLHttpRequest object.

Regular Expressions Syntax

^Start of string
$End of string
.Any single character
(a|b)a or b
(...)Group section
[abc]In range (a, b or c)
[^abc]Not in range
\sWhite space
a?Zero or one of a
a*Zero or more of a
a*?Zero or more, ungreedy
a+One or more of a
a+?One or more, ungreedy
a{3}Exactly 3 of a
a{3,}3 or more of a
a{,6}Up to 6 of a
a{3,6}3 to 6 of a
a{3,6}?3 to 6 of a, ungreedy
\Escape character
[:punct:]Any punctu­ation symbol
[:space:]Any space character
[:blank:]Space or tab

There's an excellent regular expression tester at: http:/­/re­gex­pal.com/

Pattern Modifiers

gGlobal match
i *Case-i­nse­nsitive
m *Multiple lines
s *Treat string as single line
x *Allow comments and whitespace in pattern
e *Evaluate replac­ement
U *Ungreedy pattern

* PCRE modifier

JavaScript RegExp Object

compile()lastParen
exec()leftCO­ntext
globalmultiline
ignoreCaserightC­ontext
inputsource
lastIndextest()
lastMatch
 

JavaScript Event Handlers

onAbortonMous­eDown
onBluronMous­eMove
onChangeonMouseOut
onClickonMous­eOver
onDblClickonMouseUp
onDragDroponMove
onErroronReset
onFocusonResize
onKeyDownonSelect
onKeyPressonSubmit
onKeyUponUnload
onLoad

JavaScript Arrays

concat()slice()
join()sort()
lengthsplice()
pop()toSource()
push()toString()
reverse()unshift()
shift()valueOf()

JavaScript Numbers and Maths

abs()min()
acos()NEGATI­VE_­INF­INITY
asin()PI
atan()POSITI­VE_­INF­INITY
atan2()pow()
ceil()random()
cos()round()
Esin()
exp()sqrt()
floor()SQRT1_2
LN10SQRT2
LN2tan()
log()toSource()
LOG10EtoExpo­nen­tial()
LOG2EtoFixed()
max()toPrec­ision()
MAX_VALUEtoString()
MIN_VALUEvalueOf()
NaN

JavaScript Booleans

toSource()valueOf()
toString()
 

JavaScript Dates

Date()setMonth()
getDate()setFul­lYear()
getDay()setHours()
getMonthsetMin­utes()
getFul­lYearsetSec­onds()
getYearsetMil­lis­eco­nds()
getHourssetTime()
getMinutessetUTC­Date()
getSecondssetUTC­Day()
getMil­lis­econdssetUTC­Month()
getTimesetUTC­Ful­lYear()
getTim­ezo­neO­ffset()setUTC­Hours()
getUTC­Date()setUTC­Min­utes()
getUTC­Day()setUTC­Sec­onds()
getUTC­Month()setUTC­Mil­lis­eco­nds()
getUTC­Ful­lYear()toSource()
getUTC­Hours()toString()
getUTC­Min­utes()toGMTS­tring()
getUTC­Sec­onds()toUTCS­tring()
getUTC­Mil­lis­eco­nds()toLoca­leS­tring()
parse()UTC()
setDate()valueOf()

JavaScript Strings

charAt()slice()
charCo­deAt()split() x
concat()substr()
fromCh­arC­ode()substr­ing()
indexOf()toLowe­rCase()
lastIn­dexOf()toUppe­rCase()
lengthtoLoca­leL­owe­rCase()
locale­Com­pare()toLoca­leU­ppe­rCase()
match() xtoSource()
replace() xvalueOf()
search() x

String object methods with an x support regular expres­sions.

JavaScript Functions

decode­URI()isNaN()
decode­URI­Com­pon­ent()Number()
encode­URI()parseF­loat()
encode­URI­Com­pon­ent()parseInt()
escape()String()
eval()unescape()
isFinite()
 

Share This Cheat Sheet!

Favourited by 64 Members:

chrysa Adarsh StepK Lasantha chi-zach abhisekp McCloud BobGuzek clazito Jaime MADRID Eulerintegral333 and 54 more ...

Comments

Piotrek Piotrek, 20:16 28 Feb 12

Where's typof() ?

pdf isjunk 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 Murali Prashanth N, 08:42 16 Feb 13

Thnx...dave

?????????????? ??????????????, 08:43 16 Feb 13

Wheres alert() and prompt()?

Dave Lampton Dave Lampton, 17:16 26 Mar 13

The event handlers should be all lowercase.

santsoh suryawanshi 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.

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.