Returns an iterable of entries in the map.
Adds an amount to key's value. If key is not found, it is treated as the default value. The new value is set and returned.
true if an element in the Map existed and has been removed, or false if the element does not exist.
Divides the value of key by amount. If key is not found, it is treated as the default value.
The new value is set and returned.
Returns an iterable of key, value pairs for every entry in the map.
Iterates over all keys that have a value matching fn.
// Iterate over all keys that store a value greater than 1
const greaterThanOne = (v) => v > 1;
for (const key of map.filterKeysByValue(greaterThanOne)) {
}
Predicate to test values
Returns the largest value in the map. If the map is empty, returns NaN.
// Eg find all the keys corresponding to the maximum value
const largestKeys = [...map.keysByValue(map.findValueMax())];
Returns the smallest value in the map. If the map is empty, returns NaN.
// Eg find all the keys corresponding to the minimum value
const smallestKeys = [...map.keysByValue(map.findValueMin())];
boolean indicating whether an element with the specified key exists or not.
Returns an iterable of keys in the map
Iterates over all keys that have a corresponding value
Applies a function to all values
// Round all the values
map.mapValue((value,key)=> Math.round(value));
Multiplies the value of key by amount. If key is not found, it is treated as the default value.
The new value is set and returned.
Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
Subtracts an amount from key's value. If key is not found, it is treated as the default value. The new value is set and returned.
Returns an iterable of values in the map
Staticgroup
Simple map for numbers.
Keys not present in map return the
defaultValuegiven in the constructorTo check if a key is present, use
has:Math:
Different default value:
Regular
setworks, overriding the value to whatever is given: