Arrays and Collections Flashcards

1
Q

What is wrong with the code below?

var varName = ArrayList.of(2,4,6);

A

ArrayList should be Array

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

What is an array?

A

Objects that can hold mutliple values or objects

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

How can you create an array?

A
By setting a variable to a set of empty brackets (let values = []) 
Arrays can also be created using Array.of (i.e. let values = Array.of(1,2,3)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the items in an array called?

A

Elements

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

How can you access a value in an array?

A

By specifying the index number const values = [1, 2, 3] values[0] = 1

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

How can you add items to the end of an array?

A

push()

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

How can you remove a value from the end of array?

A

pop()

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

How do you remove a value from the beginning of an array?

A

shift()

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

How do you add a value to the beginning of an array?

A

unshift()

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

What does the slice method accomplish?

A

The slice() method returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array. The original array will not be modified.

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

What method would you use to add items to the middle of an array (not beginning or end)?

A

array.splice()

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

Array.fill()

A

Changes all elements in an array to a static value from a start index (default is 0) to an end index (default is array.length). It returns a modified array.

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

What are data collections?

A
  • Stores and structures large amounts of data types for easy access.
  • Provides Methods to access that data.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are data collection types in JavaScript ES6?

A
  • Sets
  • Maps
  • WeakSets
  • WeakMaps
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a set?

A

unique values of any type (primitive or object references)

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

What is a WeakSet?

A
  • A WeakSet can only contain objects, no primitive data types
  • No iterables
  • No access to the size property