Which method adds or updates an element in a Map?
A
append() B
insert() C
set() D
add()
Analysis & Theory
`set(key, value)` adds a new key-value pair or updates an existing key in the Map.
What does the `get()` method do in a Map?
A
Removes a value B
Checks if a key exists C
Returns the value for a key D
Clears all values
Analysis & Theory
`get(key)` returns the value associated with the specified key.
Which method checks whether a Map contains a key?
A
contains() B
check() C
exists() D
has()
Analysis & Theory
`has(key)` returns `true` if the key exists in the Map, otherwise `false`.
Which method removes a specific key-value pair from a Map?
A
delete() B
remove() C
pop() D
erase()
Analysis & Theory
`delete(key)` removes the key-value pair from the Map.
What does the `clear()` method do in a Map?
A
Removes only undefined keys B
Clears all elements from the Map C
Deletes a specific key D
Sorts the Map
Analysis & Theory
`clear()` removes all key-value pairs from the Map.
How can you get the number of key-value pairs in a Map?
A
map.length B
map.count() C
map.size() D
map.size
Analysis & Theory
`map.size` is a property that gives the total number of entries in the Map.
Which method allows you to loop through each key-value pair in a Map?
A
map() B
forEach() C
entries() D
keys()
Analysis & Theory
`forEach()` allows you to run a callback on each key-value pair in the Map.
Which method returns an iterator of key-value pairs?
A
values() B
entries() C
keys() D
pairs()
Analysis & Theory
`entries()` returns an iterator of `[key, value]` pairs in insertion order.
What does `map.keys()` return?
A
An array of keys B
A string of keys C
An iterator of keys D
A Set of keys
Analysis & Theory
`keys()` returns an **iterator** over the keys in the Map.
How do you get all values in a Map?
A
map.allValues() B
map.getValues() C
map.values() D
map.toArray()
Analysis & Theory
`values()` returns an iterator of all values in the Map.