JS Methods Flashcards
1
Q
push()
A
adds item to the end of an array
ex: arr.push(‘sample’);
2
Q
pop()
A
removes item from the end of an array
ex: arr.pop();
3
Q
shift()
A
removes item from the front of the array
ex: arr.shift();
4
Q
unshift()
A
adds item to the front of the array
ex: arr.unshift(‘sample’);
5
Q
indexOf()
A
find the index of an item in array
ex: arr.indexOf(‘sample’);
6
Q
splice()
A
removes an item by index position
ex: arr.splice(pos, 1); // removes the second item
7
Q
slice()
A
copies an array
ex: arr.slice();