How to Remove a Value from a Map in JavaScript

1 week ago admin Javascript

In this lesson, we will see how to remove a value from a map in JavaScript, sometimes we want to remove a value from a map in JavaScript so how can we do that? 


The delete() method

To do that we can use the delete() method that takes the key of the value as an argument and remove it.

                                                        
                                                                                                                        
const myMap = new Map([['name','john'],['age',22],['city','london']]);
myMap.delete('name');
console.log(myMap);
//true Map(2) {'age' => 22, 'city' => 'london'}

Popular Tutorials

Related Tutorials

How to Get the Values of a Map in JavaScript

In this lesson, we will see how to get the values of a map in JavaScript, sometimes we want to get a...


How to Get the Size of a Map in JavaScript

In this lesson, we will see how to get the size of a map in JavaScript, sometimes we want to get the...


How to Check if a Map Has a Value in JavaScript

In this lesson, we will see how to check if a map has a value in JavaScript, sometimes we want to ch...


How to Get a Specific Value from a Map in JavaScript

In this lesson, we will see how to get a specific value from a map in JavaScript, sometimes we want...


How to Get the Index of a Value in an Array in JavaScript

In this lesson, we will see how to get the index of a value in an array in JavaScript, sometimes we...


How to Join Elements of an Array in JavaScript

In this lesson, we will see how to join elements of an array in JavaScript, sometimes we want to joi...


How to Check if an Array Includes a Value in JavaScript

In this lesson, we will see how to check if an array includes a value in JavaScript, sometimes we wa...


How to Remove a Specific Value from an Array in JavaScript

In this lesson, we will see how to remove a specific value from an array in JavaScript, sometimes we...


How to Add Value to an Existing Array in JavaScript

In this lesson, we will see how to add value to an existing array in JavaScript, sometimes we want t...


How to Remove Whitespace from a String in JavaScript

In this lesson, we will see how to remove whitespace from a string in JavaScript, sometimes we want&...