 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Clearing a Dictionary using Javascript
We'll implement a clear() function that simply clears the contents of the container. For example,
Example
clear() {    this.container = {} } You can test this using −
Example
const myMap = new MyMap(); myMap.put("key1", "value1"); myMap.put("key2", "value2");   myMap.display(); myMap.clear(); myMap.display(); Output
This will give the output −
{ key1: 'value1', key2: 'value2' } You can use the clear method in the same way in ES6 maps as well. For example,
Example
const myMap = new Map([ ["key1", "value1"], ["key2", "value2"] ]); console.log(myMap) myMap.clear(); console.log(myMap)
Output
This will give the output −
Map { 'key1' => 'value1', 'key2' => 'value2' } Map {}Advertisements
 