1
0
1
0
0
1
0
1
1 0
0 1
0 0
1
0
1
0
JS Array 0
1
0
1
{;}
1 0
0
1
0
1
0
1
0
0
Arrays
1
0 is a special type of variable that can hold multiple values in a
0
1 single place. These values can be numbers, strings, objects, or
0 1
1 even other arrays. 0
0 1
1 0
0
0
2 ways to create array 0
1
1 0
0 0
1 - Square Brackets ( [] ) - most common methods 1
0
0
1 1
0 1
- new Array(10) - empty slots uninitialized 0
1
1
1
[]
1
0
0
1
0 1
1
0
new Array() 0
1
1 0
0 0
0 1
1 0
0 0
1 1
0 0
1 1
0 1
.length - returns the length (size) of an array: 0
1
1
1
Index refers to the position of an element within an array.
1
0
0
1
0 1
1 0
0 1
1 0
0 0
0 1
1 0
0 0
1 1
0 0
1 1
0 1
0
1
1
1
1
0
1
0
0
1
0
1 ● One Dimensional Array 1
0
0 1
0
1 ● 2D Array 0
0
0 1
1
0
● 3D Array 0
1
1 0
0
1
● Empty Array
0
1
0
1
0
0
One Dimensional Array
1
0
0
1
an array that can be indexed as though it were a single line,
0 regardless of the number of dimensions it actually has. 1
0
1
0 1
1 0
0 0
0 1
1 0
0 0
1 1
0 0
1 1
0 1
0
1
1
1
2D Array
1
0
0
1
is a collection of data elements arranged in a grid-like
0 1
1 structure with rows and columns. 0
0 1
1 0
0 0
0 1
1 0
0 0
1 1
0 0
1 1
0 1
0
1
1
1
3D Array
1
0
0 Array of 2D arrays (layers).
1
0 1
1 0
0 1
1 0
0 0
0 1
1 0
0 0
1 1
0 0
1 1
0 1
0
1
1
1
Empty Array
1
0 An array with no elements (can be filled later).
0
1
0 1
1 0
0 1
1 0
0 0
0 1
1 0
0 0
1 1
0 0
1 1
0 1
0
1
1
1
Array Methods
1
0 are built-in functions that help you add, remove, search, loop,
0
1 and modify arrays easily.
0 1
1 push() - Adds an element to the end of an array 0
0 1
1 0
0 0
0 1
1 0
0 0
1 1
0 0
1 1
0 1
0
1
1
1
Array Methods
1
0 pop() - Removes the last element from an array
0
1
0 1
1 0
0 1
1 0
0 0
0 1
1 0
0 0
1 1
0 unshift() - Adds an element to the beginning of an array 0
1
1
0 1
0
1
1
1
Array Methods
1
0 shift() - Removes the first element from an array
0
1
0 1
1 0
0 1
1 0
0 0
0 1
1 0
0 0
1 1
0 0
1 1
0 1
0
1
1
1
Array Methods
1
0 concat() - merges two or more arrays and returns a new array
0
1 without modifying the original ones
0 1
1 0
0 1
1 0
0 0
0 1
1 0
0 0
1 1
0 0
1 1
0 1
0
1
1
1
Array Methods
1
0 join() - Converts an array into a string, joining elements using a specified
0
1 separator (default is a comma ,)
0 1
1 0
0 1
1 0
0 0
0 1
1 0
0 0
1 1
0
indexOf() - returns the index of a given element, if not found -1 0
1 1
0 1
0
1
1
1
Array Methods
1
0 includes() - Check if an element exist in the array
0
1
0 1
1 0
0 1
1 0
0 0
0 1
1 0
0 0
1 splice() - removes or replaces elements in an array 1
0 0
1 1
0 1
0
1
1
1
Array Methods
1
0 slice() - creates a copy of the selected elements instead of modifying
0
1 the original array
0 1
1 0
0 1
1 0
0 0
0 1
1 0
0 0
1 1
0 0
1 1
0 1
reverse() - reverse the order of elements. 0
1
1
1