JavaScript Map.prototype.clear() Method
JavaScript Map Instance methodThis method is supported by all modern browsers.
The clear() method removes every entry from a Map.
Description
The clear() method removes all entries from the map, leaving size at 0.
It changes the map in place, so every variable that refers to the same map sees it empty. If other code might still need the old entries, create a new Map instead of clearing the shared one.
Clearing is useful for caches that should be reset, such as when a user logs out or the data they were built from changes. Set has a clear() method that works the same way.
Syntax
map.clear()Return Value
None (undefined).
Example
Browser Support
The following information will show you the current browser support for the Map.prototype.clear() method. Hover over a browser icon to see the version that first introduced support for this method.
This method is supported by all modern browsers.
Desktop





Tablets & Mobile






-
Supported Unknown Not supported
Sponsors
Password Manager
PasswordPal stores your passwords and private notes behind encryption that happens in your browser.
Copy Paste List
Copy and paste or download lists in your preferred format, including plain text, PDF, or HTML.
Unicode Characters & Emojis
Search all Unicode characters and emojis plus other tools.
Check Shortened URLs
Expand shortened URLs to view the destination link.
Advertise Here
Advertise your company and products here!