JavaScript reference

Constructs and commands

condition alternative condition alternative condition multiple choice loop loop loop for arrays loop for objects loop break moving to next iteration function creation deleting an object property checking if a property exists executing a line of code array creation object creation

Typification

conversion to number string to number string to fraction conversion to string conversion to boolean variable type checking for a finite number checking for NaN

Special values

true value false value not a number null value undefined value infinity

Math methods

random number number rounding rounding up rounding down number rounding number rounding square root of a number power of a number maximum number minimum number absolute value of a number

Rare methods

sine of a number cosine of a number tangent of a number arcsine of a number arccosine of a number arctangent of a number e raised to the power natural logarithm exponential notation

Constants

number Pi number e natural logarithm of 2 natural logarithm of 10 base 2 logarithm of e base 10 logarithm of e square root of 1/2 square root of 2

Strings

string length lowercase uppercase splitting a string into an array substring cutting substring cutting substring cutting strings concatenation search for matches from start search for matches from end checking the string start checking the string end removing whitespaces from ends string character character by its code character code search and replacement string character by its position padding a string from the end to a given length padding a string from the start to a given length string copies creation removing whitespaces at the end of a string removing whitespaces at the start of a string search for a given string within the current string

Regexes

search and replacement with a regex matches with a regex all matches with a regex sequential search checking with a regex search with a regex splitting a string into an array

Arrays

array length merging arrays together merging an array into a string reversing an array checking for presence in an array search through an array search through an array from the end cutting off part of an array cutting off part of an array removing the first element removing the last element adding elements to the beginning adding elements to the end iterating over an array iterating over an array filtering an array all elements in an array at least one element in an array reducing to a value reducing to a value sorting an array filling an array searching for an element in an array searching for the element index in an array searching for an element from the end of an array searching for the index of an element from the end of an array getting an array from subarrays getting an array from subarrays checking if a value is an array getting an array from an array-like object getting array from parameters array element by position

Time

object for working with a date getting the year getting the month getting the day of the month getting the hours getting the minutes getting the seconds getting the milliseconds getting the day of the week date in milliseconds date from a string year setting month setting setting the day of the month hours setting minutes setting seconds setting milliseconds setting current date in milliseconds

Timers

code execution timer pause when executing a code timer reset pause reset

Getting elements

element by a selector element by an id elements by a selector element by a tag element by a class parent by a selector selector match check for a nesting

Getting relatives

all children of an element child nodes first child first child node last child last child node previous element next element parent element parent node

Parts of tables

array of table rows array of table cells table thead table tfoot table tbody

Creating elements

element creation cloning a node creating a text node

Inserting elements

insertion at the start insertion at the end insertion at the end insertion before inserting elements inserting an HTML code inserting a text

Removal

node removal removal

Text and tag

element text HTML element code external HTML code of an element node value node value tag name

Attributes

getting element attributes changing element attributes removing element attributes checking for the presence of an attribute data- attributes

CSS classes

object with classes adding classes removing classes toggling classes checking classes

Working with CSS

single line style style from css

Dimensions

full width full height left border top border content width content height

Offsets

parent with positioning top offset left offset element coordinates element at specified coordinates

Events

event binding event removal list of event types

Event object

preventing default action event type the element on which an event fired the element on which an event was hanged is it a real event whether Ctrl is pressed whether Alt is pressed whether Shift is pressed whether Cmd is pressed mouse coordinates mouse coordinates mouse coordinates mouse coordinates key code value entered character

Advanced

event constructor event simulation set focus remove focus

Context

calling a function with a context calling a function with a context context binding function invocation context

Objects

array of object keys array of object values copying objects

Popup boxes

alert box confirm box prompt box 238

Main

pen movement line drawing rectangle stroke rectangle shape rectangle circle, arc rectangle eraser

General

the beginning of a path the end of a path stroke shape fill

Settings

line width stroke color fill color line end style lines join style miter limit ratio

Working with text

text text stroke text font horizontal alignment vertical alignment text direction

Auxillary

getting started
enru