Creating and Initializing Arrays
const arr = [1,2,3]
const arr = Array.of(1,2,3)
Accessing Array Items
arr[index]
array is zero based (starts from 0)
Manipulating Arrays with methods
push()
add the values to the end of the array.
pop()
Removes the element from the end of the array.
shift()
Removes the element from the beginning of the array
unshift()
add the values to begining of the array
slice() and splice()
slice()
slice(begin, end)
Returns a shallow copy of a portion of an array into a new array object selected from begin to end (end not included)
splice()
splice(idx, deleteCount, newItems)
Changes the contents of an array by removing or replacing existing elements and/or adding new elements in place.
Array Searching and Looping
indexOf()
find()
Returns value of the first element in the provided array that satisfies the provided testing function
filter()
Creates a new array with all elements that pass the test implemented by the provided function
forEach()
executes a provided function once for each array element
Arrays in the DOM
document.getElementsByClassName()
'Study > Coding' 카테고리의 다른 글
DOM objects/elements (0) | 2020.05.22 |
---|---|
Scope and Hoisting (0) | 2020.03.01 |
Objects (0) | 2020.02.17 |
Functions (0) | 2020.02.12 |
Program Flow (0) | 2020.02.12 |