The API for Map and WeakMap is very similar when it comes to standard operations, such as set() and get(). This makes the API very straightforward and contains the following:
- Map.prototype.size: Returns the size of the map; not available on typical objects unless you loop and count
- Map.prototype.set: Sets a value for a given key and returns the entire new map
- Map.prototype.get: Gets a value for a given key and returns undefined if not found
- Map.prototype.delete: Deletes a value for a given key and returns true if deletion was successful, otherwise false
- Map.prototype.has: Checks the map for the presence of an element with the key provided; returns boolean
- Map.prototype.clear: Clears the map; returns nothing
- Map.prototype.forEach ...