Awesome JavaScript Reference
Awesome JavaScript
Reference
JavaScript Glossary of Terms
Ajax- "(asynchronous JavaScript and XML)" – set
of web development techniques using
many web technologies
on the client-side to create asynchronous
Web applications.With Ajax, web
applications can send data
to and retrieve from a server asynchronously
(in the background) without interfering
with the display and
behavior of the existing page.
of web development techniques using
many web technologies
on the client-side to create asynchronous
Web applications.With Ajax, web
applications can send data
to and retrieve from a server asynchronously
(in the background) without interfering
with the display and
behavior of the existing page.
Algorithm- set of computer instructions
to produce an output
or end state from an input
or beginning state. What programs
are made of.
to produce an output
or end state from an input
or beginning state. What programs
are made of.
Arity- refers to the number of arguments
an operator takes.
ex: a binary function
takes two arguments
an operator takes.
ex: a binary function
takes two arguments
Attribute- An attribute is a modifier
of an element type.
of an element type.
Bookmarklet- technique of saving
JavaScript within a bookmark
or hyperlink, so that it can
be executed by clicking on it.
In many cases, the link can be dragged
and dropped to the browser
toolbar for easier access.
JavaScript within a bookmark
or hyperlink, so that it can
be executed by clicking on it.
In many cases, the link can be dragged
and dropped to the browser
toolbar for easier access.
Chaining- also known as cascading,
refers to repeatedly calling
one method
after another on an object, in one
continuous line of code.
refers to repeatedly calling
one method
after another on an object, in one
continuous line of code.
Currying- refers to the process of
transforming a function with
multiple arity into the
same function with less arity
transforming a function with
multiple arity into the
same function with less arity
DRY- Don't Repeat Yourself
Document Object Model- (DOM) the
hierarchy (tree) produced
by the browser of all the
elements of a webpage. By processing the DOM
via "methods" (functions stored as object
properties, that is, the actions
that can be performed
on objects), JavaScript can dynamically
change the page's HTML.
hierarchy (tree) produced
by the browser of all the
elements of a webpage. By processing the DOM
via "methods" (functions stored as object
properties, that is, the actions
that can be performed
on objects), JavaScript can dynamically
change the page's HTML.
ECMAScript- the specification language upon
which JavaScript is based. The terms
"EMCAScript" and "JavaScript" are used
interchangeably within the field.
'ES' has also been
used as a prefix for shorthand names
of versions of JavaScript.
which JavaScript is based. The terms
"EMCAScript" and "JavaScript" are used
interchangeably within the field.
'ES' has also been
used as a prefix for shorthand names
of versions of JavaScript.
Event- action or occurrence recognized by
software, often originating asynchronously from
the external environment, that may be handled
by the software. Computer events can be
generated or triggered by the system, by the
user (via keystrokes or a mouse clicks),
or in other ways.
software, often originating asynchronously from
the external environment, that may be handled
by the software. Computer events can be
generated or triggered by the system, by the
user (via keystrokes or a mouse clicks),
or in other ways.
Event-driven programming- software
that changes its
behavior in response to events is
said to be event-driven, often with the
goal of being interactive.
that changes its
behavior in response to events is
said to be event-driven, often with the
goal of being interactive.
First-class function- the functions
of a language are
first-class functions if they are
first-class objects.
The functions in JavaScript
are first-class objects,
and therefore, first-class functions.
of a language are
first-class functions if they are
first-class objects.
The functions in JavaScript
are first-class objects,
and therefore, first-class functions.
First-class object- entity which supports all the
operations generally available to other
entities (such as data types). These operations
typically include being passed as an argument,
returned from a function, modified, and assigned
to a variable. In JavaScript, functions are
first-class objects.
operations generally available to other
entities (such as data types). These operations
typically include being passed as an argument,
returned from a function, modified, and assigned
to a variable. In JavaScript, functions are
first-class objects.
Higher Order Functions- functions that accept
other functions as an argument
other functions as an argument
JSON- stands for JavaScript Object Notation,
an open-standard file format that uses
human-readable text to transmit data objects
consisting of attribute–value pairs and array
data types (or any other serializable value).
It is a very common data format used for
asynchronous browser–server communication,
including as a replacement for XML in
some AJAX-style systems.
an open-standard file format that uses
human-readable text to transmit data objects
consisting of attribute–value pairs and array
data types (or any other serializable value).
It is a very common data format used for
asynchronous browser–server communication,
including as a replacement for XML in
some AJAX-style systems.
Predicate- a calculation or other operation
that would evaluate either to "true" or “false.”
that would evaluate either to "true" or “false.”
Recursion- an approach in which
a function calls itself
a function calls itself
Scope- the set of variables, objects, and
functions available within a
certain block of code
functions available within a
certain block of code
var- The most common variable. Can be
reassigned but only accessed within a function.
Variables defined with var move to the top
when the code is executed.
reassigned but only accessed within a function.
Variables defined with var move to the top
when the code is executed.
const- Can not be reassigned
and not accessible
before they appear within the code.
and not accessible
before they appear within the code.
let- Similar to const, the let variable can be
reassigned but not re-declared.
reassigned but not re-declared.
Objects- Certain kind of variables. They are
variables which can have
their own values and methods.
variables which can have
their own values and methods.
concat()- Join several arrays into one
indexOf()- Returns the primitive
value of the specified object
value of the specified object
join()- Combine elements of an array into a
single string and return the string
single string and return the string
lastIndexOf()- Gives the last position at which
a given element appears in an array
a given element appears in an array
pop()- Removes the last element of an array
push()- Add a new element at the end
reverse()- Sort elements in a descending order
shift()- Remove the first element of an array
slice()- Pulls a copy of a portion
of an array into a new array
of an array into a new array
sort()- Sorts elements alphabetically
splice()- Adds elements in a
specified way and position
specified way and position
toString()- Converts elements to strings
unshift()- Adds a new element to the beginning
valueOf()- Returns the first position at which a
given element appears in an array
given element appears in an array
alert()- Output data in an alert box in the browser window
confirm() - Opens up a yes/no dialog and
returns true/false depending on user click
returns true/false depending on user click
console.log()- Writes information to the
browser console, good for debugging purposes
browser console, good for debugging purposes
document.write()- Write directly
to the HTML document
to the HTML document
prompt()- Creates a dialogue for user input
Basic Operators
+ -Addition
- - Subtraction
* - Multiplication
/ - Division
(...) - Grouping operator, operations within
brackets are executed
earlier than those outside
brackets are executed
earlier than those outside
% - Modulus (remainder )
++ - Increment numbers
-- - Decrement numbers
Comparison Operators
== - Equal to
=== - Equal value and equal type
!= - Not equal
!== - Not equal value or not equal type
> - Greater than
< - Less than
>= - Greater than or equal to
<= - Less than or equal to
Logical Operators
&& - Logical and
|| - Logical or
! - Logical not
Bitwise Operators
& - AND statement
| - OR statement
~ - NOT
^ - XOR
<< - Left shift
>> - Right shift
>>> - Zero fill right shift
String Object Methods
charAt()
|
returns the character at the specified index
|
concat()
|
joins two or more strings, and
returns a copy of the joined strings |
indexOf()
|
returns the position of the first found
occurence of a specified value in a string |
lastIndexOf()
|
returns the position of the last found
occurence of a specified value in a string |
replace()
|
searches for a match between a
substring (or regex) and a string, and replaces the matched substring with a new substring |
search()
|
searches for a match between a regex
and a string, and returns the position of the match |
slice()
|
extracts a part of a string and returns
a new string |
split()
|
splits a string into an array of substrings
|
substr()
|
extracts the characters from a string,
beginning at a specified start position, and through the specified number of character |
substring()
|
extracts the characters from a string,
between two specified indices |
toLowerCase()
|
converts a string to lowercase letters
|
toUpperCase()
|
converts a string to uppercase letters
|
trim()
|
removes whitespace from both ends of a string
|
valueOf()
|
returns the primitive value of a String object
|
toString()
|
returns the value of a String object
|
Math Object Methods
abs(x)
|
returns the absolute value of x
|
round(x)
|
rounds x to the nearest integer
|
ceil(x)
|
returns x, upwards to the nearest integer
|
floor(x)
|
returns x, rounded downwards to the nearest integer
|
exp(x)
|
returns the value of Ex
|
log(x)
|
returns the narural logarithm (base E) of x
|
max(x, y, z, ...)
|
returns the number with the highest value
|
min(x, y, z, ...)
|
returns the number with the lowest value
|
pow(x, y)
|
returns the value of x to the power of y (xy)
|
sqrt(x)
|
returns the square root of x
|
random()
|
returns a random number between 0 and 1
|
sin(x)
|
returns the sine of x (x in radians)
|
cos(x)
|
returns the cosine of x (x in radians)
|
tan(x)
|
returns the tangent of an x
|
Event handlers
onAbort loading stopped
onBlur focus lost
onChange content modified
onClick clicked
onDblClick clicked twice
onDragDrop moved
onError not loaded
onFocus focus entered
onKeyDown key depressed
onKeyPress key pressed
onKeyUp key released
onLoad just after loading
onMouseDown mouse button depressed
onMouseMove mouse moved
onMouseOut mouse exited
onMouseOver mouse on the element
onMouseUp mouse button released
onReset reset form button clicked
onResize size of page changed
onSelect element selected
onSubmit submit form button clicked
onUnload page exited
Accessing DOM Elements
document.getElementById(id); - Returns
a reference to the element by its ID.
document.getElementsByClassName(names); -
Returns an array-like object of all child elements
which have all of the given class names.
document.getElementsByTagName(name); -
Returns an HTMLCollection of elements with the
given tag name.
a reference to the element by its ID.
document.getElementsByClassName(names); -
Returns an array-like object of all child elements
which have all of the given class names.
document.getElementsByTagName(name); -
Returns an HTMLCollection of elements with the
given tag name.
document.querySelector(selectors); -
Returns the first element within the document that matches
the specified group of selectors.
Returns the first element within the document that matches
the specified group of selectors.
document.querySelectorAll(selectors); -
Returns a list of the elements within the document
(using depth-first pre-order traversal of the
document's nodes) that match the specified group
of selectors.
Comments
// Single-line comments start with two slashes.
/* Multiline comments start with slash-star,
and end with star-slash */
Events
<button onclick="myFunction();">
Click here
</button>
Click here
</button>
Mouse
onclick, oncontextmenu, ondblclick,
onmousedown, onmouseenter, onmouseleave,
onmousemove, onmouseover, onmouseout, onmouseup
onmousedown, onmouseenter, onmouseleave,
onmousemove, onmouseover, onmouseout, onmouseup
Keyboard
onkeydown, onkeypress, onkeyup
Frame
onabort, onbeforeunload, onerror,
onhashchange, onload, onpageshow, onpagehide,
onresize, onscroll, onunload
onhashchange, onload, onpageshow, onpagehide,
onresize, onscroll, onunload
Form
onblur, onchange, onfocus, onfocusin,
onfocusout, oninput, oninvalid,
onreset, onsearch,
onselect, onsubmit
onfocusout, oninput, oninvalid,
onreset, onsearch,
onselect, onsubmit
Drag
ondrag, ondragend, ondragenter,
ondragleave, ondragover, ondragstart, ondrop
ondragleave, ondragover, ondragstart, ondrop
Clipboard
oncopy, oncut, onpaste
Media
onabort, oncanplay, oncanplaythrough,
ondurationchange, onended, onerror, onloadeddata,
onloadedmetadata, onloadstart, onpause,
onplay, onplaying, onprogress, onratechange,
onseeked, onseeking, onstalled, onsuspend,
ontimeupdate, onvolumechange, onwaiting
ondurationchange, onended, onerror, onloadeddata,
onloadedmetadata, onloadstart, onpause,
onplay, onplaying, onprogress, onratechange,
onseeked, onseeking, onstalled, onsuspend,
ontimeupdate, onvolumechange, onwaiting
Animation
animationend, animationiteration, animationstart
Miscellaneous
transitionend, onmessage, onmousewheel,
ononline, onoffline, onpopstate, onshow, onstorage,
ontoggle, onwheel, ontouchcancel, ontouchend,
ontouchmove, ontouchstart
ononline, onoffline, onpopstate, onshow, onstorage,
ontoggle, onwheel, ontouchcancel, ontouchend,
ontouchmove, ontouchstart
Global Functions
eval(); - executes a string as if it was script code
String(16); - return string from number
(16).toString(); - return string from number
Number("16"); - return number from string
decodeURI(enc); - decode URI. Result: "my page.asp"
encodeURI(uri); - encode URI. Result: "my%page.asp"
decodeURIComponent(enc); - decode a URI component
encodeURIComponent(uri); - encode a URI component
isFinite(); - is variable a finite, legal number
isNaN(); - is variable an illegal number
parseFloat(); - returns floating point number of string
parseInt(); - parses a string and returns an integer
Reserved Keywords
abstract else instanceof super
boolean enum int switch
break export interface synchronized
byte extends let this
case false long throw
catch final native throws
char finally new transient
class float null true
const for package try
continue function private typeof
debugger goto protected var
default if public void
delete implements return volatile
do import short while
double in static with
boolean enum int switch
break export interface synchronized
byte extends let this
case false long throw
catch final native throws
char finally new transient
class float null true
const for package try
continue function private typeof
debugger goto protected var
default if public void
delete implements return volatile
do import short while
double in static with
Identifiers
alert frames outerHeight
all frameRate outerWidth
anchor function packages
anchors getClass pageXOffset
area hasOwnProperty pageYOffset
Array hidden parent
assign history parseFloat
blur image parseInt
button images password
checkbox Infinity pkcs11
clearInterval isFinite plugin
clearTimeout isNaN prompt
clientInformation isPrototypeOf propertyIsEnum
close java prototype
closed JavaArray radio
confirm JavaClass reset
constructor JavaObject screenX
crypto JavaPackage screenY
Date innerHeight scroll
decodeURI innerWidth secure
decodeURIComponent layer select
defaultStatus layers self
document length setInterval
element link setTimeout
elements location status
embed Math String
embeds mimeTypes submit
encodeURI name taint
encodeURIComponent NaN text
escape navigate textarea
eval navigator top
event Number toString
fileUpload Object undefined
focus offscreenBuffering unescape
form open untaint
forms opener valueOf
frame option window
all frameRate outerWidth
anchor function packages
anchors getClass pageXOffset
area hasOwnProperty pageYOffset
Array hidden parent
assign history parseFloat
blur image parseInt
button images password
checkbox Infinity pkcs11
clearInterval isFinite plugin
clearTimeout isNaN prompt
clientInformation isPrototypeOf propertyIsEnum
close java prototype
closed JavaArray radio
confirm JavaClass reset
constructor JavaObject screenX
crypto JavaPackage screenY
Date innerHeight scroll
decodeURI innerWidth secure
decodeURIComponent layer select
defaultStatus layers self
document length setInterval
element link setTimeout
elements location status
embed Math String
embeds mimeTypes submit
encodeURI name taint
encodeURIComponent NaN text
escape navigate textarea
eval navigator top
event Number toString
fileUpload Object undefined
focus offscreenBuffering unescape
form open untaint
forms opener valueOf
frame option window
Additional Handlers
onbeforeunload ondragdrop onkeyup onmouseover
onblur onerror onload onmouseup
ondragdrop onfocus onmousedown onreset
onclick onkeydown onmousemove onsubmit
oncontextmenu onkeypress onmouseout onunload
Comments
Post a Comment