Arrays Flashcards

1
Q

Code an array iteration

A

let bestColors = [‘green’, ‘blue’, ‘yellow’]
bestColors.forEach( x => console.log(x))

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

Each content item inside an array is called

A

An element

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

Each element in an array has a numbered position known as

A

It’s index

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

How many ways are there to declare array and what are they?

A

Two
Literal notation:
let newArr = []

Constructor

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

True or False: Arrays in JavaScript are zero-indexed

A

True

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

What are arrays?

A

A data structure to store ordered collections (collections of elements)

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

What does pop() do?

A

Removes the last item of the array

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

What does shift() do?

A

The shift() method removes the first element from an array and returns that removed element. This method changes the length of the array

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

What does unshift() do?

A

The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array

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

What does zero-indexed mean?

A

The positions start counting from 0 rather than 1

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

What is an array literal?

A

Creates an array by wrapping items in square brackets []

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

What is the difference between .forEach and .map()?

A

.map() returns a new array

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

What is an array underneath the hood?

A

An object

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