0% found this document useful (0 votes)
3 views

JS Array

The document provides an overview of arrays in JavaScript, explaining their structure and types, including one-dimensional, two-dimensional, and three-dimensional arrays. It also details methods for creating arrays and built-in functions for manipulating them, such as push, pop, unshift, and splice. Additionally, it covers array properties like length and indexing, as well as methods for searching and modifying arrays.

Uploaded by

Marcus Bautista
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

JS Array

The document provides an overview of arrays in JavaScript, explaining their structure and types, including one-dimensional, two-dimensional, and three-dimensional arrays. It also details methods for creating arrays and built-in functions for manipulating them, such as push, pop, unshift, and splice. Additionally, it covers array properties like length and indexing, as well as methods for searching and modifying arrays.

Uploaded by

Marcus Bautista
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

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

You might also like