Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
242 views

Complete Javascript Cheat Sheet

The document provides a summary of common JavaScript array and string methods. It lists array methods such as concat(), copyWithin(), entries(), every(), filter(), find(), findIndex(), forEach(), includes(), indexOf(), and isArray(). It also lists string methods such as charAt(), charCodeAt(), concat(), endsWith(), fromCharCode(), includes(), indexOf(), lastIndexOf(), localeCompare(), match(), repeat(), and replace(). The document provides brief descriptions of what each method does in 1-2 sentences.

Uploaded by

31 Raj Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
242 views

Complete Javascript Cheat Sheet

The document provides a summary of common JavaScript array and string methods. It lists array methods such as concat(), copyWithin(), entries(), every(), filter(), find(), findIndex(), forEach(), includes(), indexOf(), and isArray(). It also lists string methods such as charAt(), charCodeAt(), concat(), endsWith(), fromCharCode(), includes(), indexOf(), lastIndexOf(), localeCompare(), match(), repeat(), and replace(). The document provides brief descriptions of what each method does in 1-2 sentences.

Uploaded by

31 Raj Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

Complete

JavaScript
Cheat
Sheet
Arrays

Array Properties

constructor length

In JavaScript, the constructor property returns the The length property sets or returns the number of
constructor function for an object. For JavaScript arrays elements in an array.
the constructor property returns function Array() { [native
code] }

prototype

The prototype constructor allows you to add new


properties and methods to the Array() object.

Array Methods

concat() copyWithin()

The concat() method is used to join two or more arrays. copies array elements to another position in the array,
This method does not change the existing arrays, but overwriting the existing values. This method will never
returns a new array, containing the values of the joined add more items to the array. Note: this method overwrites
arrays. the original array.

page 1
Arrays

Array Methods

entries() every()

The entries() method returns an Array Iterator object with The every() method checks if all elements in an array pass
key/value pairs. a test (provided as a function).

fill() filter()

The fill() method fills the specified elements in an array The filter() method creates an array filled with all array
with a static value. You can specify the position of where elements that pass a test (provided as a function).
to start and end the filling. If not specified, all elements
will be filled.

find() findIndex()

The find() method returns the value of the first element in The findIndex() method returns the index of the first
an array that pass a test (provided as a function). element in an array that pass a test (provided as a function).

page 2
Arrays

Array Methods

forEach() includes()

The forEach() method calls a function once for each The includes() method determines whether an array
element in an array, in order. contains a specified element.

indexOf() isArray()

The indexOf() method searches the array for the specified The isArray() method determines whether an object is an
item, and returns its position. array.Thinction returns true if the object is an array, and
false if not.

join() lastIndexOf()

Convert the elements of an array into a string. The join() The lastIndexOf() method searches the array for the
method returns the array as a string. specified item, and returns its position.

page 3
Arrays

Array Methods

map() pop()

The map() method creates a new array with the results of The pop() method removes the last element of an array,
calling a function for every array element. and returns that element.

push() reduce()

The push() method adds new items to the end of an array, The reduce() method executes a provided function for
and returns the new length. each value of the array (from left-to-right) and reduces the
array to a single value.

reduceRight() reverse()

The reduceRight() method executes a provided function The reverse() method reverses the order of the elements
for each value of the array (from right-to-left) and reduces in an array.
the array to a single value.

page 4
Arrays

Array Methods

some() slice()

The slice() method selects the elements starting at the


The some() method checks if any of the elements in an
given start argument, and ends at, but does not include,
array pass a test (provided as a function). It executes the
the given end argument. It returns the selected elements
function once for each element present in the array
in an array, as a new array object.

shift() sort()

The shift() method removes the first item of an array. The sort() method sorts the items of an array.

splice() toString()

The splice() method adds/removes items to/from an array, The toString() method returns a string with all the array
and returns the removed item(s). values, separated by commas.

page 5
Arrays

Array Methods

unshift() valueOf()

The valueOf() method returns the array. This method is the


The unshift() method adds new items to the beginning of
default method of the array object. Array.valueOf() will
an array, and returns the new length.
return the same as Array

page 6
Strings

String Methods

charAt() charCodeAt()

The charAt() method returns the character at the specified The charCodeAt() method returns the Unicode of the
index in a string. The index of the first character is 0, the character at the specified index in a string.
second character is 1, and so on.

concat() endsWith()

The concat() method is used to join two or more strings. The endsWith() method determines whether a string ends
This method does not change the existing strings, but with the characters of a specified string. This method
returns a new string containing the text of the joined returns true if the string ends with the characters, and
strings. false if not.

fromCharCode() includes()

The fromCharCode() method converts Unicode values into The includes() method determines whether a string
characters. This is a static method of the String object, contains the characters of a specified string.
and the syntax is always String.fromCharCode()

page 7
Strings

String Methods

indexOf() lastIndexOf()

The indexOf() method returns the position of the first The lastIndexOf() method returns the position of the last
occurrence of a specified value in a string. This method occurrence of a specified value in a string. The string is
returns -1 if the value to search for never occurs. searched from the end to the beginning, but returns the
index starting at the beginning, at position 0.

localeCompare() match()

The localeCompare() method compares two strings in the The match() method searches a string for a match against
current locale. The locale is based on the language a regular expression, and returns the matches, as an Array
settings of the browser. object.
Returns -1 if str1 is sorted before str2
Returns 0 if the two strings are equal
Returns 1 if str1 is sorted after str2

repeat() replace()

The repeat() method returns a new string with a specified The replace() method searches a string for a specified
number of copies of the string it was called on. value, or a regular expression, and returns a new string
where the specified values are replaced.

page 8
Strings

String Methods

search() slice()

The search() method searches a string for a specified The slice() method extracts parts of a string and returns
value, and returns the position of the match. the extracted parts in a new string.

split() startsWith()

The split() method is used to split a string into an array of The startsWith() method determines whether a string
substrings, and returns the new array. begins with the characters of a specified string.

substr() substring()

The substr() method extracts parts of a string, beginning The substring() method extracts the characters from a
at the character at the specified position, and returns the string, between two specified indices, and returns the new
specified number of characters. sub string.

page 9
Strings

String Methods

toLocaleLowerCase() toLocaleUpperCase()

The toLocaleUpperCase() method converts a string to


The toLocaleLowerCase() method converts a string to
uppercase letters, according to the host's current locale.
lowercase letters, according to the host's current locale.

toLowerCase() toUpperCase()

The toLowerCase() method converts a string to lowercase The toUpperCase() method converts a string to uppercase
letters. It does not change the original string. letters. It does not change the original string.

trim()

The trim() method removes whitespace from both sides of


a string. It does not change the original string.

page 10
Browser Window

Window Properties

closed frameElement

The frameElement property returns the <iframe> element


The closed property returns a Boolean value indicating
in which the current window is inserted. If the document
whether a window has been closed or not.The closed
window is not placed within an <iframe>, the return value
property returns a Boolean value indicating whether a
of this property is null.
window has been closed or not.

frames innerWidth and innerHeight

The frames property returns an array-like object, which The innerWidth property returns the width of a window's
represents all <iframe> elements in the current window. content area.
The <iframe> elements can be accessed by index numbers. The innerHeight property returns the height of a window's
The index starts at 0. content area.
These properties are read-only.

page 11
Browser Window

Window Properties

length localStorage

The localStorage and sessionStorage properties allow to


The length property returns the number of <iframe>
save key/value pairs in a web browser.
elements in the current window.

name parent

The name property sets or returns the name of the The parent property returns the parent window of the
window. This property is often used to modify the name current window.
of a window,

OuterHeight and OuterWidth opener

The opener property returns a reference to the window


The outerWidth property returns the outer width of the
that created the window.
browser window, including all interface elements (like opener
toolbars/scrollbars).

page 12
Browser Window

Window Properties

pageXOffset and pageYOffset screenX and screenY

The pageXOffset and pageYOffset properties returns the The screenX and screenY properties returns the x
pixels the current document has been scrolled from the (horizontal) and y (vertical) coordinates of the window
upper left corner of the window, horizontally and relative to the screen.
vertically.

screenLeft and screenTop

The screenLeft and screenTop properties returns the x


(horizontal) and y (vertical) coordinates of the window
relative to the screen.

page 13
Browser Window

Window Methods

alert() atob()

The alert() method displays an alert box with a specified The atob() method decodes a base-64 encoded string.
message and an OK button. This method decodes a string of data which has been
encoded by the btoa() method.

blur() btoa()

The blur() method removes focus from the current The btoa() method encodes a string in base-64.
window.

page 14
Browser Window

Window Methods

clearInterval() clearTimeout()

The clearInterval() method clears a timer set with the The clearTimeout() method clears a timer set with the
setInterval() method. The ID value returned by setInterval() setTimeout() method.
is used as the parameter for the clearInterval() method.

close() confirm()

The close() method closes the current window. The confirm() method displays a dialog box with a
specified message, along with an OK and a Cancel button.

focus() getSelection()

The focus() method sets focus to the current window. Returns a Selection object representing the range of text
selected by the user

page 15
Browser Window

Window Methods

getComputedStyle() matchMedia()

The getComputedStyle() method gets all the actual The window.matchMedia() method returns a MediaQueryL-
(computed) CSS property and values of the specified ist object representing the results of the specified CSS
element. media query string.

moveBy() moveTo()

The moveBy() method moves a window a specified The moveTo() method moves a window's left and top edge
number of pixels relative to its current coordinates. to the specified coordinates.

open() print()

The open() method opens a new browser window, or a The print() method opens the Print Dialog Box, which lets
new tab, depending on your browser settings and the the user to select preferred printing options.
parameter values.

page 16
Browser Window

Window Methods

prompt() resizeBy()

The prompt() method displays a dialog box that prompts The resizeBy() method resizes a window by the specified
the visitor for input. amount, relative to its current size.

resizeTo() scrollBy()

The resizeTo() method resizes a window to the specified The scrollBy() method scrolls the document by the
width and height. specified number of pixels.

scrollTo() setInterval()

The scrollTo() method scrolls the document to the The setInterval() method calls a function or evaluates an
specified coordinates. expression at specified intervals (in milliseconds).

page 17
Browser Window

Window Methods

setTimeout() stop()

The setTimeout() method calls a function or evaluates an The stop() method stops window loading.
expression after a specified number of milliseconds.

page 18
Console Methods

Console Methods

console.assert() console.clear()

The console.clear() method clears the console. It will also


The console.assert() method writes a message to the
write a message in the console: "Console was cleared".
console, but only if an expression evaluates to false.

console.count() console.error()

he console.error() method writes an error message to the


Writes to the console the number of times that particular
console.The console is useful for testing purposes.
console.count() is called. You can add a label that will be
included in the console view.

console.group() console.groupCollapsed()

The console.groupCollapsed() method indicates the start


The console.group() method indicates the start of a
of a collapsed message group. Click the expand button to
message group.All messages will from now on be written
open the message group.
inside this group.

page 19
Console Methods

Console Methods

console.groupEnd() console.table()

The console.table() method writes a table in the console


The console.groupEnd() method indicates the end of a
view. The first parameter is required, and must be either
message group.
an object, or an array, containing data to fill the table.

console.info() console.log()

The console.info() method writes a message to the The console.log() method writes a message to the console.
console. The console is useful for testing purposes.

console.time() console.warn()

Use the console.time() method to start the timer. The The console.warn() method writes a warning to the
console.timeEnd() method ends a timer, and writes the console.
result in the console view.

page 20
The Document Object

The Document Object

adoptNode() anchors

The adoptNode() method adopts a node from another The anchors collection returns a collection of all <a>
document. elements in the document that have a name attribute.

baseURI body

The baseURI property returns the base URI of the HTML The body property sets or returns the document's body.
document. This property is read-only.

close() cookie

The close() method closes the output stream previously The cookie property sets or returns all name/value pairs
opened with the document.open() method of cookies in the current document.

page 21
The Document Object

The Document Object

characterSet createComment()

The characterSet property returns the character encoding The createComment() method creates a Comment node
for the document. with the specified text.

createAttribute() createDocumentFragment()

The createAttribute() method creates an attribute with the The createDocumentFragment() method creates an
specified name, and returns the attribute as an Attr object. imaginary Node object, with all the properties and
methods of the Node object.

createElement() createEvent()

The createElement() method creates an Element Node The createDocumentFragment() method creates an
with the specified name.The createElement() method imaginary Node object, with all the properties and
creates an Element Node with the specified name. methods of the Node object.

page 22
The Document Object

The Document Object

createTextNode() createComment()

The createTextNode() method creates a Text Node with the The createComment() method creates a Comment node
specified text. with the specified text.

defaultView designMode

The defaultView property returns the document's Window The designMode property sets or returns whether the
Object. document is editable or not.

documentElement documentURI

The documentElement property returns the documentEle- The documentURI property sets or returns the location of
ment of the document, as an Element object. For HTML a document. If the document was created by the
documents the returned object is the <html> element. DocumentImplementation object, or if it is undefined, the
return value is null.

domain embeds

The domain property returns the domain name of the The embeds collection returns a collection of all
server that loaded the current document. <embeds> elements in the document.

page 23
The Document Object

The Document Object

execCommand() forms

The execCommand() method executes the specified The forms collection returns a collection of all <form>
command for the selected part of an editable section. elements in the document.

fullscreenElement fullscreenEnabled()

The fullscreenElement property returns the current The fullscreenEnabled() method returns a Boolean value
element that is displayed in fullscreen mode, or null when indicating whether the document can be viewed in
not in fullscreen. fullscreen mode.

getElementById() getElementsByClassName()

The getElementById() method returns the element that The getElementsByClassName() method returns a
has the ID attribute with the specified value. collection of all elements in the document with the
specified class name

page 24
The Document Object

The Document Object

getElementsByName() getElementsByTagName()

The getElementsByName() method returns a collection of The getElementsByTagName() method returns a collection
all elements in the document with the specified name (the of all elements in the document with the specified tag
value of the name attribute) name, as an HTMLCollection object.

hasFocus() head

The hasFocus() method returns a Boolean value indicating The head property returns the <head> element of the
whether the document (or any element inside the current document.
document) has focus.

images implementation

The images collection returns a collection of all <img> The implementation property returns the DOMimplemen-
elements in the document. tation object that handles this document, as a Documen-
tImplementation object.

page 25
The Document Object

The Document Object

inputEncoding lastModified

The inputEncoding property returns the character The lastModified property returns the date and time the
encoding for the document. current document was last modified.

links normalize()

The links collection returns a collection of all links in the The normalize() method removes empty Text nodes, and
document. joins adjacent Text nodes.

normalizeDocument() open()

The normalizeDocument() method removes empty Text The open() method opens an output stream to collect the
nodes, and joins adjacent Text nodes. output from any document.write() or document.writeln()
methods.

querySelector querySelectorAll()

The normalizeDocument() method removes empty Text The querySelectorAll() method returns all elements in the
nodes, and joins adjacent Text nodes. document that matches a specified CSS selector(s), as a
static NodeList object.

page 26
The Document Object

The Document Object

readyState referrer

The readyState property returns the (loading) status of the The referrer property returns the URL of the document
current document. that loaded the current document.

removeEventListener() scripts

The document.removeEventListener() method removes an The scripts collection returns a collection of all <script>
event handler that has been attached with the elements in the document.
document.addEventListener() method.

title URL

The title property sets or returns the title of the current The URL property returns the full URL of the current HTML
document (the text inside the HTML title element). document.

write() writeln()

The write() method writes HTML expressions or JavaScript The writeln() method is identical to the document.write()
code to a document. method, with the addition of writing a newline character
after each statement.

page 27
History Object

History Object

length back()

The length property returns the number of URLs in the The back() method loads the previous URL in the history
history list of the current browser window. list.

forward() go()

The forward() method loads the next URL in the history The go() method loads a specific URL from the history list.
list.

page 28
Screen Object

Screen Object

availHeight availWidth

The availHeight property returns the height of the user's The availWidth property returns the width of the user's
screen, in pixels, minus interface features like the screen, in pixels, minus interface features like the
Windows Taskbar. Windows Taskbar.

colorDepth height

The colorDepth property returns the bit depth of the color The height property returns the total height of the user's
palette for displaying images (in bits per pixel). screen, in pixels.

pixelDepth width

The pixelDepth property returns the color resolution (in The width property returns the total width of the user's
bits per pixel) of the visitor's screen. screen, in pixels.

page 29
Navigator Object

Navigator Object

appCodeName appName

The appCodeName property returns the code name of the The appName property returns the name of the browser.
browser.

appVersion cookieEnabled

The appVersion property returns the version information The cookieEnabled property returns a Boolean value that
of the browser. specifies whether cookies are enabled in the browser.

geolocation language

The geolocation property returns a Geolocation object The language property returns the language version of the
that can be used to locate the user's position. browser.

page 30
Navigator Object

Navigator Object

onLine product

The onLine property returns a Boolean value that specifies The product property returns the engine (product) name
whether the browser is in online or offline mode. of the browser.

userAgent platform

The userAgent property returns the value of the The platform property returns for which platform the
user-agent header sent by the browser to the server. browser is compiled.

page 31
Geolocation Object

Geolocation Object

coordinates position

The coordinates property returns the position and altitude The position property returns the position and altitude of
of the device on Earth. the device on Earth.

positionError positionOptions

Returns the reason of an error occurring when using the Describes an object containing option properties to pass
geolocating device as a parameter of Geolocation.getCurrentPosition() and
Geolocation.watchPosition()

clearWatch() getCurrentPosition()

Unregister location/error monitoring handlers previously Returns the current position of the device
installed using Geolocation.watchPosition()

watchPosition()

Returns a watch ID value that then can be used to


unregister the handler by passing it to the Geolocation.-
clearWatch() method

page 32
Location Object

Location Object

hash host

The hash property sets or returns the anchor part of a The host property sets or returns the hostname and port
URL, including the hash sign (#). of a URL.

hostname href

The hostname property sets or returns the hostname of a The href property sets or returns the entire URL of the
URL. current page.

origin pathname

The origin property returns the protocol, hostname and The pathname property sets or returns the pathname of a
port number of a URL. URL.

page 33
Location Object

Location Object

port search

The port property sets or returns the port number the The search property sets or returns the querystring part of
server uses for a URL. a URL, including the question mark (?).

assign() reload()

The assign() method loads a new document. The reload() method is used to reload the current
document.

replace()

The replace() method replaces the current document with


a new one.

The difference between this method and assign(), is that


replace() removes the URL of the current document from
the document history, meaning that it is not possible to
use the "back" button to navigate back to the original
document.

page 34
HTML DOM Events

HTML DOM Events

abort afterprint

The abort event occurs when the loading of an The afterprint event occurs when a page has started
audio/video has been aborted, and not because of an printing, or if the print dialogue box has been closed.
error.

animationend animationiteration

The animationend event occurs when a CSS animation has The animationiteration event occurs when a CSS anima-
completed. tion is repeated.

animationstart beforeprint

The animationstart event occurs when a CSS animation The beforeprint event occurs when a page is about to be
has started to play. printed (before the print dialogue box appears).

page 35
HTML DOM Events

HTML DOM Events

beforeunload blur

The onbeforeunload event occurs when the document is The onblur event occurs when an object loses focus. The
about to be unloaded. onblur event is most often used with form validation code
(e.g. when the user leaves a form field).

canplay canplaythrough

The oncanplay event occurs when the browser can start The oncanplaythrough event occurs when the browser
playing the specified audio/video (when it has buffered estimates it can play through the specified media without
enough to begin). having to stop for buffering.

change click

The onchange event occurs when the value of an element The onclick event occurs when the user clicks on an
has been changed. element.

contextmenu copy

The oncontextmenu event occurs when the user The oncopy event occurs when the user copies the content
right-clicks on an element to open the context menu. of an element.

page 36
HTML DOM Events

HTML DOM Events

cut dblclick

The oncut event occurs when the user cuts the content of The ondblclick event occurs when the user double-clicks
an element. on an element.

drag dragend

The ondrag event occurs when an element or text The ondragend event occurs when the user has finished
selection is being dragged. dragging an element or text selection.

dragenter dragleave

The ondragenter event occurs when a draggable element The ondragleave event occurs when a draggable element
or text selection enters a valid drop target. or text selection leaves a valid drop target.

dragover dragstart

The ondragover event occurs when a draggable element or The ondragstart event occurs when the user starts to drag
text selection is being dragged over a valid drop target. an element or text selection.

page 37
HTML DOM Events

HTML DOM Events

drop durationchange

The ondrop event occurs when a draggable element or The ondurationchange event occurs when the duration of
text selection is dropped on a valid drop target. the audio/video is changed.

ended error

The onended event occurs when the audio/video has The onerror event is triggered if an error occurs while
reached the end. loading an external file (e.g. a document or an image).

focus focusin

The onfocus event occurs when an element gets focus. The The onfocusin event occurs when an element is about to
onfocus event is most often used with <input>, <select>, get focus.
and <a>.

focusout fullscreenchange

The onfocusout event occurs when an element is about to The fullscreenchange event occurs when an element is
lose focus. viewed in fullscreen mode.

page 38
HTML DOM Events

HTML DOM Events

fullscreenerror hashchange

The fullscreenerror event occurs when an element can not The onhashchange event occurs when there has been
be viewed in fullscreen mode, even if it has been request- changes to the anchor part (begins with a '#' symbol) of
ed. the current URL.

input invalid

The oninput event occurs when an element gets user The oninvalid event occurs when a submittable <input>
input. This event occurs when the value of an <input> or element is invalid.
<textarea> element is changed.

keydown keypress

The onkeydown event occurs when the user is pressing a The onkeypress event occurs when the user presses a key
key (on the keyboard). (on the keyboard).

keyup load

The onkeyup event occurs when the user releases a key The onload event occurs when an object has been loaded.
(on the keyboard).

page 39
HTML DOM Events

HTML DOM Events

loadeddata loadedmetadata

The onloadeddata event occurs when data for the current The onloadedmetadata event occurs when meta data for
frame is loaded, but not enough data to play next frame of the specified audio/video has been loaded.
the specified audio/video.

loadstart message

The onloadstart event occurs when the browser starts The onmessage event occurs when a message is received
looking for the specified audio/video. This is when the through an event source.
loading process starts.

mousedown mouseenter

The onmousedown event occurs when a user presses a The onmouseenter event occurs when the mouse pointer
mouse button over an element. is moved onto an element.

mouseleave mousemove

The onmouseleave event occurs when the mouse pointer The onmousemove event occurs when the pointer is
is moved out of an element. moving while it is over an element.

page 40
HTML DOM Events

HTML DOM Events

mouseover mouseout

The onmouseover event occurs when the mouse pointer is The onmouseout event occurs when the mouse pointer is
moved onto an element, or onto one of its children. moved out of an element, or out of one of its children.

mouseup offline

The onmouseup event occurs when a user releases a The onoffline event occurs when the browser starts to
mouse button over an element. work offline.

online open

The ononline event occurs when the browser starts to The onopen event occurs when a connection with an event
work online. source is opened.

pagehide pageshow

The onpagehide event occurs when the user is navigating The onpageshow event occurs when a user navigates to a
away from a webpage. webpage.

page 41
HTML DOM Events

HTML DOM Events

paste pause

The onpaste event occurs when the user pastes some The onpause event occurs when the audio/video is
content in an element. paused either by the user or programmatically.

play playing

The onplay event occurs when the audio/video has been The onplaying event occurs when the audio/video is
started or is no longer paused. playing after having been paused or stopped for buffering.

progress ratechange

The onprogress event occurs when the browser is The onratechange event occurs when the playing speed of
downloading the specified audio/video. the audio/video is changed

resize reset

The onresize event occurs when the browser window has The onreset event occurs when a form is reset.
been resized.

page 41
HTML DOM Events

HTML DOM Events

scroll seeked

The onscroll event occurs when an element's scrollbar is The onseeked event occurs when the user is finished
being scrolled. moving/skipping to a new position in the audio/video

seeking select

The onseeking event occurs when the user starts The onselect event occurs after some text has been
moving/skipping to a new position in the audio/video. selected in an element.

show stalled

The onshow event occurs when a <menu> element is The onstalled event occurs when the browser is trying to
shown as a context menu. get media data, but data is not available.

submit suspend

The onsubmit event occurs when a form is submitted. The onsuspend event occurs when the browser is
intentionally not getting media data.

page 43
HTML DOM Events

HTML DOM Events

timeupdate toggle

The ontimeupdate event occurs when the playing position The ontoggle event occurs when the user opens or closes
of an audio/video has changed. the <details> element.

touchcancel touchend

The touchcancel event occurs when the touch event gets The touchend event occurs when the user removes the
interrupted. finger from an element.

touchmove touchstart

The touchmove event occurs when the user moves the The touchstart event occurs when the user touches an
finger across the screen. element.

transitionend unload

The transitionend event occurs when a CSS transition has The onunload event occurs once a page has unloaded (or
completed. the browser window has been closed).

page 44
HTML DOM Events

HTML DOM Events

volumechange waiting

The onvolumechange event occurs each time the volume The onwaiting event occurs when the video stops because
of a video/audio has been changed. it needs to buffer the next frame.

wheel

The onwheel event occurs when the mouse wheel is rolled


up or down over an element.

page 45
DOM Event Properties and Methods

DOM Event Properties and Methods

MouseEvent altKey KeyboardEvent altKey

The altKey property returns a Boolean value that indicates The altKey property returns a Boolean value that indicates
whether or not the "ALT" key was pressed when a mouse whether or not the "ALT" key was pressed when a key
event was triggered. event was triggered.

AnimationEvent animationName bubbles

The animationName property returns the name of the The bubbles event property returns a Boolean value that
animation, when an animation event occurs. indicates whether or not an event is a bubbling event.

MouseEvent button MouseEvent buttons

The button property returns a number that indicates The buttons property returns a number that indicates
which mouse button was pressed when a mouse event was which mouse button or mouse buttons were pressed when
triggered. a mouse event was triggered.

page 46
DOM Event Properties and Methods

DOM Event Properties and Methods

cancelable KeyboardEvent charCode

The cancelable event property returns a Boolean value The charCode property returns the Unicode character code
indicating whether or not an event is a cancelable event. of the key that triggered the onkeypress event.

MouseEvent clientX MouseEvent clientY

The clientX property returns the horizontal coordinate The clientY property returns the vertical coordinate
(according to the client area) of the mouse pointer when a (according to the client area) of the mouse pointer when a
mouse event was triggered. mouse event was triggered.

KeyboardEvent code createEvent()

The code property returns the key that triggered the event. The createEvent() method creates an event object.

page 47
DOM Event Properties and Methods

DOM Event Properties and Methods

MouseEvent ctrlKey currentTarget

The ctrlKey property returns a Boolean value that The currentTarget event property returns the element
indicates whether or not the "CTRL" key was pressed when whose event listeners triggered the event.
a mouse event was triggered.

InputEvent data defaultPrevented

The data property returns the character that was inserted The defaultPrevented event property checks whether the
with the event. preventDefault() method was called for the event.

WheelEvent deltaX WheelEvent deltaY

The deltaX property returns a positive value when The deltaY property returns a positive value when
scrolling to the right, and a negative value when scrolling scrolling down, and a negative value when scrolling up,
to the left, otherwise 0. otherwise 0.

page 48
DOM Event Properties and Methods

DOM Event Properties and Methods

WheelEvent deltaZ WheelEvent deltaMode

The deltaZ property returns a positive value when The deltaMode property returns a number representing
scrolling in, and a negative value when scrolling out, the length unit of the scrolling values (deltaX, deltaY, and
otherwise 0. deltaZ).

UiEvent detail AnimationEvent elapsedTime

The detail property returns a number with details about The elapsedTime property returns the number of seconds
the event. an animation has been running, when an animation event
occurs.

TransitionEvent elapsedTime eventPhase

The elapsedTime property returns the number of seconds The eventPhase event property returns a number that
a transition has been running, when a transitionend event indicates which phase of the event flow is currently being
occurs. evaluated.

page 49
DOM Event Properties and Methods

DOM Event Properties and Methods

MouseEvent getModifierState() InputEvent inputType

The getModifierState() method returns true if the specified The inputType property returns the type of change that
modifier key was pressed, or activated. was done by the event.

isTrusted KeyboardEvent key

The isTrusted event property returns a Boolean value The key property returns the identifier of the key that was
indicating whether the event is trusted or not. pressed when a key event occured.

KeyboardEvent keyCode KeyboardEvent key

The keyCode property returns the Unicode character code The key property returns the identifier of the key that was
of the key that triggered the onkeypress event pressed when a key event occured.

page 50
DOM Event Properties and Methods

DOM Event Properties and Methods

KeyboardEvent metaKey MouseEvent metaKey

The metaKey property returns a Boolean value that The metaKey property returns a Boolean value that
indicates whether or not the "META" key was pressed when indicates whether or not the "META" key was pressed when
a key event was triggered. a mouse event was triggered.

KeyboardEvent location HashChangeEvent newURL

The location property returns a number that indicates the The newURL property returns the URL of the document,
location of a key on the keyboard or device. after the hash (anchor part) has been changed.

MouseEvent pageY MouseEvent pageX

The pageY property returns the vertical coordinate The pageX property returns the horizontal coordinate
(according to the document) of the mouse pointer when a (according to the document) of the mouse pointer when a
mouse event was triggered. mouse event was triggered.

page 51
DOM Event Properties and Methods

DOM Event Properties and Methods

HashChangeEvent oldURL PageTransitionEvent persisted

The oldURL property returns the URL of the document, The persisted property returns a Boolean value that
before the hash (anchor part) was changed. indicates if the webpage is loaded directly from the server

preventDefault() TransitionEvent propertyName

The preventDefault() method cancels the event if it is The propertyName property returns the name of the CSS
cancelable, meaning that the default action that belongs property associated with the transition, when a transition-
to the event will not occur. event occurs.

MouseEvent relatedTarget MouseEvent shiftKey

The relatedTarget property returns the element related to The relatedTarget property returns the element related to
the element that triggered the mouse event. the element that The shiftKey property returns a Boolean
value that indicates whether or not the "SHIFT" key was
pressed when a mouse event was triggered.triggered the
focus/blur event.

page 52
DOM Event Properties and Methods

DOM Event Properties and Methods

KeyboardEvent shiftKey stopImmediatePropagation()

The shiftKey property returns a Boolean value that The stopImmediatePropagation() method prevents other
indicates whether or not the "SHIFT" key was pressed listeners of the same event from being called.
when a key event was triggered.

stopPropagation() target

The stopPropagation() method prevents propagation of The target event property returns the element that
the same event from being called. triggered the event.

stopPropagation() target

The stopPropagation() method prevents propagation of The target event property returns the element that
the same event from being called. triggered the event.

page 53
DOM Event Properties and Methods

DOM Event Properties and Methods

TouchEvent targetTouches timeStamp

The targetTouches property returns an array of Touch The timeStamp event property returns the number of
objects, one for each finger that is touching the current milliseconds from the document was finished loading until
target element. the specific event was created.

TouchEvent touches transitionend Event

The touches property returns an array of Touch objects, The transitionend event occurs when a CSS transition has
one for each finger that is currently touching the surface. completed.

type MouseEvent which

The type event property returns the type of the triggered The which property returns a number that indicates which
event. mouse button was pressed when a mouse event was
triggered.

page 54
DOM Event Properties and Methods

DOM Event Properties and Methods

KeyboardEvent which view

The which property returns the Unicode character code of The view event property returns a reference to the Window
the key that triggered the onkeypress event, object where the event occured.

page 54

You might also like