JS Methods Flashcards

1
Q

push()

A

adds item to the end of an array

ex: arr.push(‘sample’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

pop()

A

removes item from the end of an array

ex: arr.pop();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

shift()

A

removes item from the front of the array

ex: arr.shift();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

unshift()

A

adds item to the front of the array

ex: arr.unshift(‘sample’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

indexOf()

A

find the index of an item in array

ex: arr.indexOf(‘sample’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

splice()

A

removes an item by index position

ex: arr.splice(pos, 1); // removes the second item

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

slice()

A

copies an array

ex: arr.slice();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly