Map Flashcards

1
Q

Map is similar to what DS?

A

Object. Both operate w/ key value pairs.

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

Key types

A

Any value (array, Objs, or any primitive)

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

Key order

A

A Map iterates in the order of insertion

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

Is a Map iterable?

A

Yes. Can be directly iterated.

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

Which performs better, Object or Map?

A

Map when frequently adding & removing kv pairs.

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

How to return the number of elements?

A

Map.size

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

Map.clear()

A

Does- removes all elements from Map object

Params- none

Returns- undefined

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

Map.delete()

A

Does- removes a specified element

Params- key

Returns- bool. True if object existed and was removed. False if it doesn’t exist

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

Map.entries() vs Map.keys() vs Map.values()

A

Entries - returns a new Map iterator w/ key-value pairs in insertion order

Keys - returns a new Map iterator w/ all keys in insertion order

Values- returns a new Map iterator w/ all values in insertion order

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

Map.get()

A

Does- returns a specified element from Map object

Params -Key

Returns - associated elements value or undefined

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

Map.set()

A

Does - inserts/updates a key-value in Map object

Params - key, value

Returns Map object

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

Map.has()

A

Does - tells if key exists in Map object

Params - key

Returns - bool based on if key exists

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