Built-ins

IDNameDescriptionTypeModuleStepExplanationExample
1 alert

alert

JS 1 3

Create a new window containing the message.

The result of alert("Click now") is a box with the string "Click now" which needs to be clicked for you to regain control of your machine.

2 document.write

document write

JS 1 3

Replaces the content of the page with the input.

The result of document.write("message") is a page with "message" on it.

3 console.log

console log

JS 1 3

Prints the input to the console.

The result of console(5) is the printing of 5 to the console.

4 var

variable or constant declaration

JS 2 7

Used to declare a variable or a constant.

Using var cost declares a variable, and var cost = 100; also initializes it.

5 undefined

undefined

JS 2 7

A built-in value, such as the value of a variable that has not been initialized.

The value of a variable that has not been initialized is undefined.

6 null

null

JS 2 9

A built-in value.

The type of null is object.

7 typeof

typeof function

JS 2 9

A function that returns the type of the input.

The value of typeof(5) is "number".

8 Infinity

infinity

JS 2 10

A special number for infinite values.

The value of 7 / 0 is Infinity.

9 -Infinity

negative infinity

JS 2 10

A special number for infinite negative values.

The value of -7 / 0 is -Infinity.

10 NaN

not a number

JS 2 10

A special value to indicate that what has been obtained is not a number.

The value of Infinity / -Infinity is NaN. Paradoxically, the type of NaN is "number".

11 +

addition/concatenation

JS 2 10

Used to add two numbers or concatenate two strings.

The value of 2 + 3 is 5 and the value of "a" + "b" is "ab".

12 -

subtraction

JS 2 10

Used to subtract a number from a number.

The value of 5 - 2 is 3.

13 *

multiplication

JS 2 10

Used to multiply two numbers.

The value of 2 * 3 is 6.

14 /

division

JS 2 10

Used to divide a number by a number.

The value of 6 / 2 is 3.

15 %

remainder

JS 2 10

Used to determine the remainder when dividing one number by another.

The value of 6 % 4 is 2.

16 +=

add and update

JS 2 12

Used to add a value to a variable.

The result of a += b is the same as the result of a = a + b.

17 -=

subtract and update

JS 2 12

Used to subtract a value from a variable.

The result of a -= b is the same as the result of a = a - b.

18 ++

increment

JS 2 12

Used to increment a variable.

The result of a++ is the same as the result of a = a + 1.

19 --

decrement

JS 2 12

Used to decrement a variable.

The result of a-- is the same as the result of a = a - 1.

20 \'

escape character for single quote

JS 2 13

Used to include a single quotation mark in a string.

An example of a string is "What\'s that?".

21 \"

escape character for double quote

JS 2 13

Used to include a double quotation mark in a string.

An example of a string is "You are my \"friend\"."

22 \n

escape character for new line

JS 2 13

Used to indicate where a new line starts in a string.

An example of a string is "One\ntwo"; this appears on two lines.

23 \t

escape character for tab

JS 2 13

Used to indicate where a tab is placed in a string.

An example of a string is "One\ttwo", with a tab between the two words.

24 \\

escape character for backslash

JS 2 13

Used to include a backslash in a string.

An example of a string is "This is a backslash: \\".

25 true

Boolean value

JS 2 14

The Boolean constant true.

The value of true is true.

26 false

Boolean value

JS 2 14

The Boolean constant false.

The value of false is false.

27 Boolean()

Boolean function

JS 2 14

Produces the Boolean equivalent of the input.

The value of Boolean("cat") is true.

28 <

less than

JS 2 15

Produces true when the first input has a value less than the second input.

The value of 3 < 4 is true.

29 <=

less than or equal to

JS 2 15

Produces true when the first input has a value less than or equal to the second input.

The value of 6 <= 2 is false.

30 >

greater than

JS 2 15

Produces true when the first input has a value less than the second input.

The value of 3 > 3 is false.

31 >=

greater than or equal to

JS 2 15

Produces true when the first input has a value greater than or equal to the second input.

The value of 4 >= 4 is true.

32 ==

equal

JS 2 15

Produces true when the first input has a value equal to the second input, allowing type conversion.

The value of 2 == 2 is true.

33 !=

not equal

JS 2 15

Produces true when the first input has a value not equal to the second input, allowing type conversion.

The value of 2 != 1 is true.

34 ===

equal (same type)

JS 2 15

Produces true when the first input has a value equal to the second input, no type conversion allowed.

The value of 2 === 2 is true.

35 !==

not equal (same type)

JS 2 15

Produces true when the first input has a value not equal to the second input, no type conversion allowed.

The value of 2 !== 3 is true.

36 &&

Boolean and

JS 2 15

Produces true when both smaller expressions are true.

The value of true && false is false.

37 ||

Boolean or

JS 2 15

Produces true when at least one smaller expression is true.

The value of false || true is true.

38 !

Boolean not

JS 2 15

Produces true when the value is False and False when the value is true.

The value of !false is true.

39 Number()

number function

JS 2 18

Produces the number equivalent (if any) of the input.

The value of Number("5") is 5.

40 String()

string function

JS 2 18

Produces the string equivalent (if any) of the input.

The value of String(5) is "5".

41 .length

length property

JS 3 2

A string property with value the number of characters in the string.

The value of "hat".length is 3.

42 .valueOf()

value of method

JS 3 2

A method of any input, giving its value.

The value of valueOf(3) is 3.

43 .toString()

to string method

JS 3 2

A method of any input, giving its string equivalent.

The value of 3.toString is "3".

44 .slice(start, stop)

slice method

JS 3 4

Produces a string with characters positions start through stop - 1.

The value of "hat".slice(1, 2) is "a".

45 .indexOf(sub)

index of method

JS 3 4

Produces the first position where sub is found, or -1 if it is not present.

The value of "hat".indexOf("a") is 1.

46 .charAt(index)

char at method

JS 3 4

Produces the character at position index if index is a valid position in the string.

The value of "hat".charAt(2) is "t".

47 .toUpperCase()

to upper case method

JS 3 4

Produces the string with all lower-case letters replaced by upper-case letters.

The value of "One hat?".toUpperCase is "ONE HAT?".

48 .toLowerCase()

to lower case method

JS 3 4

Produces the string with all upper-case letters replaced by lower-case letters.

The value of "One hat?".toLowerCase is "one hat?".

49 .replace(old, new)

replace method

JS 3 4

Produces the string with the first copy of substring old replaced by substring new.

The value of "hat".replace("h","c") is "cat".

50 Math.PI

constant pi

JS 3 5

The constant pi.

The value of Math.PI is an approximation of pi, 3.141592653589793.

51 Math.floor(n)

math floor

JS 3 5

Produces the nearest integer below n.

The value of Math.floor(2.5) is 2.

52 Math.ceil(n)

math ceiling

JS 3 5

Produces the nearest integer above n.

The value of Math.ceil(2.5) is 3.

53 Math.max(a, b, c)

math maximum

JS 3 5

Produces the maximum of the inputs.

The value of Math.max(1, 2, 3) is 3.

54 Math.min(a, b, c)

math minimum

JS 3 5

Produces the minimum of the inputs.

The value of Math.min(1, 2, 3) is 1.

55 Math.pow(a, b)

math exponent

JS 3 5

Produces a to the power b.

The value of Math.pow(2, 3) is 8.

56 Math.sqrt(n)

math square root

JS 3 5

Produces the square root of n.

The value of Math.sqrt(4) is 2.

57 Math.random()

math random

JS 3 5

Produces a pseudorandom number in the range [0,1).

The value of Math.random() * 10 is a pseudorandom number in the range from 0 to 9.

58 new Date()

date function

JS 3 6

Produces a new date object.

59 .getFullYear()

get full year method

JS 3 6

Produces the full year of a date object.

60 .getMonth()

get month method

JS 3 6

Produces the month of a date object, numbered from 0 to 11.

61 .getDate()

get date method

JS 3 6

Produces the date of a date object, with days numbered starting from 1.

62 .getHours()

get hours method

JS 3 6

Produces the hours of a date object.

63 .getMinutes()

get minutes method

JS 3 6

Produces the minutes of a date object.

64 .getSeconds()

get seconds method

JS 3 6

Produces the seconds of a date object.

65 .setMonth()

set month method

JS 3 6

Sets the month of the data object to the input month.

66 .toDateString()

to date string method

JS 3 6

Gives a readable format to a date object.

67 canvas.getContext("2d")

get context method

JS 3 9

Retrieves the context object.

68 lineWidth

line width property

JS 3 9

A canvas property with value the width of the line in pixels.

69 strokeStyle

stroke style property

JS 3 9

A canvas property with value a string giving the colour of the line.

70 lineCap

line cap property

JS 3 9

A canvas property with value a string indicating how the ends of the line can be shaped, such as "butt", "round", and "square".

71 fillStyle

fill style property

JS 3 9

A canvas property with value a string giving the colour of a closed path.

72 font

font property

JS 3 9

A canvas property with value a string giving the size and name of a font.

73 .moveTo(x, y)

move to method

JS 3 10

A canvas method that places the pen at point (x, y).

74 .lineTo(x, y)

line to method

JS 3 10

A canvas method that forms a line by moving the pen to point (x, y).

75 .stroke()

stroke method

JS 3 10

A canvas method that makes a line appear using lineWidth and strokeStyle.

76 .beginPath()

begin path method

JS 3 10

A canvas method that starts a new shape.

77 .closePath()

close path method

JS 3 10

A canvas method that closes of the shape formed.

78 .fill()

fill method

JS 3 10

A canvas method that fills what was created.

79 .rect(x, y, w, h)

rectangle method

JS 3 12

A canvas method that creates a rectangle of width w and height h with the top left corner at (x, y).

80 .arc(x, y, r, s, e)

arc method

JS 3 12

A canvas method that creates an arc of a circle centred at (x, y) with radius r from starting angle s to ending angle e.

81 .fillText(text, x, y)

fill text method

JS 3 12

A canvas method that places text at (x, y).

82 documentElement

document element property

JS 4 2

A DOM property of the document node, meaning the html element.

83 head

head property

JS 4 2

A DOM property of the document node, meaning the head element.

84 body

body property

JS 4 2

A DOM property of the document node, meaning the body element.

85 nodeType

node type property

JS 4 2

A DOM property of any node with value a number indicating the type.

86 nodeName

node name property

JS 4 2

A DOM property of any node with value a string with tag name in upper case, attribute name, or "#text".

87 nodeValue

node value property

JS 4 2

A DOM property of any node with value null for an element node, the attribute value for an attribute node and the content for a text node.

88 .getElementById()

get element by ID method

JS 4 2

A DOM method that produces the element with the ID equal to the input string.

89 parentNode

parent node property

JS 4 4

A DOM property with value the parent node.

90 firstChild

first child property

JS 4 4

A DOM property with value the first child node.

91 firstElementChild

first element property

JS 4 4

A DOM property with value the first child that is an element node.

92 lastChild

last child property

JS 4 4

A DOM property with value the last child node.

93 lastElementChild

last element child property

JS 4 4

A DOM property with value the last child that is an element node.

94 nextSibling

next sibling property

JS 4 4

A DOM property with value the next sibling node.

95 nextElementSibling

next element sibling property

JS 4 4

A DOM property with value the next sibling that is an element node.

96 previousSibling

previous sibling property

JS 4 4

A DOM property with value the previous sibling node.

97 previousElementSibling

previous element sibling property

JS 4 4

A DOM property with value the previous sibling that is an element node.

98 innerHTML

inner HTML property

JS 4 6

A DOM property with value the entire HTML content of the element.

99 textContent

text content property

JS 4 6

A DOM property with value the concatenation of the text of all the descendants of the node.

100 style

style property

JS 4 6

A DOM property with value the style of a node.

101 .getAttribute(attribute)

get attribute method

JS 4 6

A DOM method that produces the value of a particular attribute.

102 .setAttribute(attribute, value)

set attribute method

JS 4 8

A DOM method that sets the value of a particular attribute.

103 document.createElement("tagname")

create element method

JS 4 10

A DOM method that creates an element node with the specified tag name.

104 document.createTextNode("new text")

create text node method

JS 4 10

A DOM method that creates a text node with the specified text content.

105 .appendChild(item)

append child method

JS 4 10

A DOM method that adds item as the last child of the object.

106 .insertBefore(item, previousChild)

insert before method

JS 4 10

A DOM method that inserts item before the child previousChild of the object.

107 .replaceChild(item, oldChild)

replace child method

JS 4 10

A DOM method that replaces the child oldChild of the object with item.

108 .removeChild(oldChild)

remove child method

JS 4 13

A DOM method that removes the child oldChild of the object.

109 window.onload

window load

JS 5 9

The event when the window loads.

110 .addEventListener(event, function)

add event listener method

JS 5 11

A method that specifies that the function should be executed when the event occurs.

111 if

if

JS 6 2

Used to introduce the condition and the sequence of steps to execute if the condition is true.

112 else if

else if

JS 6 2

Used to introduce another condition and the sequence of steps to execute if that condition is true.

113 else

else

JS 6 2

Used to introduce the sequence of steps to execute if no other branches have been taken.

114 switch

switch

JS 6 5

Used to specify an expression, the value of which is used to distinguish among cases.

115 case

case

JS 6 5

Used to specify a possible value of an expression in a switch statement.

116 break

break statement

JS 6 5

Used to specify a break in a switch statement or an early exit from a loop.

117 while

while loop

JS 6 7

Used for a while loop.

118 for

for loop

JS 6 7

Used for a for loop.

119 continue

continue statement

JS 6 7

Used to specify an exit out of the current iteration in a loop.

120 [item1, item2, item3]

create array

JS 7 2

Used to create a new array.

121 myArray[i]

array index

JS 7 2

Used to access the item in the array at index i.

The value of [4, 5][0] is 4.

122 myArray.length

array length

JS 7 2

Used to specify one greater than the largest index storing an element.

The value of [4, 5].length is 2.

123 .split(string)

split method

JS 7 2

A string method that consumes a string and produces an array of strings formed by splitting using the input string.

The value of "a-b-c".split("-") is ["a", "b", "c"].

124 .concat(arrayOne, arrayTwo)

concatenation method

JS 7 6

An array method that returns a new array formed by concatenating arrayOne and arrayTwo to the array; one or more arguments can be used.

The value of [3].concat([4, 5]) is [3, 4, 5].

125 .toString()

to string method

JS 7 6

An array method that returns a string formed by concatenating all the items, using the string "," between each consecutive pair.

The value of [4, 5].toString() is "4,5".

126 .join(joiner)

join method

JS 7 6

An array method that returns a string formed by concatenating all the items, using the string joiner between each consecutive pair.

The value of [4, 5].join("-") is "4-5".

127 .indexOf(item)

index of method

JS 7 6

An array method that returns the index of the leftmost occurrence of the item.

The value of [4, 5, 4].indexOf(4) is 0.

128 .lastIndexOf(item)

last index of method

JS 7 6

An array method that returns the index of the rightmost occurrence of the item.

The value of [4, 5, 4].lastIndexOf(4) is 2.

129 .slice(start, end)

slice method

JS 7 6

An array method that returns a new array formed including elements with index start up through end - 1.

The value of [4, 5, 6].slice(1,2) is [5].

130 .slice(start)

slice method (one index)

JS 7 6

An array method that returns a new array formed including elements with index start up through the end of the original array.

The value of [4, 5, 6].slice(1) is [5, 6].

131 .push(itemOne, itemTwo)

push method

JS 7 7

An array method that adds the arguments (one or more) to the end of the array and returns the new array length.

Calling [4, 5].push(6) results in the array [4, 5, 6] and the return value 3.

132 .pop()

pop method

JS 7 7

An array method that removes the last item from the array and returns it.

Calling [4, 5].pop() results in the array [4] and the return value 5.

133 .shift()

shift method

JS 7 7

An array method that removes the first item from the array and returns it.

Calling [4, 5].shift() results in the array [5] and the return value 4.

134 .unshift(item)

unshift method

JS 7 7

An array method that adds item to the beginning of the array and returns the array length.

Calling [4].unshift(5) results in the array [5, 4] and the return value 2.

135 .splice(i, num, itemOne, itemTwo)

splice method

JS 7 8

An array method that splices in the items to add (the third and following arguments) at index i while removing num items, and returns an array of the items removed.

Calling [4, 5, 6, 7, 8].split(1, 2, 9, 10) results in the array [4, 9, 10, 7, 8] and the return value [5, 6].

136 .reverse()

reverse method

JS 7 8

An array method that reverse the order of the items and returns the modified array.

Calling [4, 5].reverse() results in the array [5, 4] and the return value [5, 4].

137 .sort()

sort method

JS 7 8

An array method that sorts the items in alphabetical order and returns the modified array.

Calling [8, 6].sort() results in the array [6, 8] and the return value [6, 8].

138 .forms()

forms method

JS 7 11

A DOM method of the document object that returns all form elements in the body.

139 .images()

images method

JS 7 11

A DOM method of the document object that returns all images elements in the body.

140 .links()

links method

JS 7 11

A DOM method of the document object that returns all hyperlink elements in the body.

141 .getElementsByClassName(class)

get elements by class name method

JS 7 11

A DOM method that returns all elements with the specified class name.

142 .getElementsByTagName(tag)

get elements by tag name method

JS 7 11

A DOM method that returns all elements with the specified tag name.

143 .getElementsByName(name)

get elements by name method

JS 7 11

A DOM method of the document object that returns all elements with the specified name.

144 .childNodes()

child nodes method

JS 7 11

A DOM method that returns all children.

145 .querySelectorAll(selector)

query selector all method

JS 7 11

A DOM method that returns all elements matching the input selector.

146 objectName = {property: value}

create object

JS 8 2

Used to create an object.

147 object[property]

extract property

JS 8 2

Used to extract a property value of an object.

148 delete

delete property

JS 8 2

Used to delete a property from an object.

149 for (prop in object)

for loop in an object

JS 8 2

Used to loop over all properties in an object.

150 function Classname()

create class

JS 8 4

Used to create a class.

151 new ClassName()

create object of a class

JS 8 4

Used to create an object of a particular class.

152 i

case insensitive modifier

JS 8 10

Used an a case-insensitive modifier in a regular expression.

153 g

global modifier

JS 8 10

Used as a global modifier in a regular expression.

154 m

multiline matching modifier

JS 8 10

Used as a multiline match in a regular expression.

155 .search(exp)

search method

JS 8 10

A string method that consumes a regular expression and produces the position of the first match.

156 .replace(exp, replace)

replace method

JS 8 10

A string method that consumes a regular expression and replacement string and produces the string formed by replacing each substring matching the pattern by the replacement string.

157 (a|b)

pattern a or b

JS 8 12

Used in a regular expression for either string a or string b.

158 [a3]

pattern any character

JS 8 12

Used in a regular expression for any character in the brackets.

159 [3-5]

pattern character range

JS 8 12

Used in a regular expression for any character in the range.

160 \d

pattern digit

JS 8 12

Used in a regular expression for any digit.

161 \s

pattern white space

JS 8 12

Used in a regular expression for white space.

162 \b

pattern match at beginning or ending

JS 8 12

Used in a regular expression to show that the match is at the beginning or ending.

163 +

pattern at least one

JS 8 12

Used in a regular expression to indicate at least of what comes before.

164 *

pattern zero or more

JS 8 12

Used in a regular expression to indicate zero or more of what comes before.

165 ?

pattern zero or one

JS 8 12

Used in a regular expression to indicate zero or one of what comes before.