Javascript Flashcards

1
Q

How do you add an item to an array?

A

var myArray = [‘a’, ‘b’, ‘c’, ‘d’];

myArray.push(“end”);

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

How do you add an item to the beginning of an array?

A

var myArray = [‘a’, ‘b’, ‘c’, ‘d’];

myArray.unshift(“start”);

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