JavaScript weakMap delete() Method Last Updated : 23 May, 2023 Comments Improve Suggest changes Like Article Like Report The weakMap.delete() is an inbuilt function in JavaScript which is used to delete a particular element from an object WeakMap. Syntax: weakMap.delete(key); Parameters: It accepts a parameter "key" which is the key of the element which is going to be deleted from the object weakMap. Return values: It returns true if that element has been deleted from the weakMap object and false if that key is not present in the weakMap object. Below are examples of weakMap.delete() method. Example 1: javascript function gfg() { const weakmap = new WeakMap(); const key = {}; weakmap.set(key, 6); console.log(weakmap.delete(key)); } gfg(); Output: true Example 2: javascript // Creating a WeakMap() object const weakmap1 = new WeakMap(); // Creating a key "key1" const key1 = {}; // Setting the value 6 with key1 to the // the end of weakMap object console.log(key1, 6); // Deleting key of the element from // the weakMap object console.log(weakmap1.delete(key1)); Output: true Example 3: javascript // Creating a WeakMap() object const weakmap1 = new WeakMap(); // Creating a key "key1" const key1 = {}; // Deleting key of the element from // the weakMap object console.log(weakmap1.delete(key1)); Output: false Explanation: Here output is false because the key "key1" with any value has not been set to the end of the weakMap object. Supported Browser: Chrome 36 and aboveEdge 12 and aboveFirefox 6 and aboveInternet Explorer 11 and aboveOpera 23 and aboveSafari 8 and above We have a complete list of Javascript weakMap methods, to check those please go through this JavaScript WeakMap Complete Reference article. We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript. Comment More infoAdvertise with us Next Article JavaScript weakMap get() Method S ShivamKD Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Weakmap JavaScript-Methods Similar Reads JavaScript WeakMap() Constructor The WeakMap() Constructor produces WeakMap objects that are a key/value pair array in which the key is referenced weakly. The keys should be objects and the values could be arbitrary. The difference between Map and WeakMap is that keys must be objects and are only weakly referenced. This means that 2 min read JavaScript WeakMap constructor Property JavaScript WeakMap constructor property is used to return the WeakMap constructor function for the object. The function returned by this property is just the reference, not the actual WeakMap. It is an object property of JavaScript and can be used with Strings, Numbers, etc. Syntax: weakset.construc 1 min read JavaScript weakMap delete() Method The weakMap.delete() is an inbuilt function in JavaScript which is used to delete a particular element from an object WeakMap. Syntax: weakMap.delete(key); Parameters: It accepts a parameter "key" which is the key of the element which is going to be deleted from the object weakMap. Return values: It 2 min read JavaScript weakMap get() Method The Javascript weakMap.get() is an inbuilt function in JavaScript that is used to return a particular element from an object WeakMap. Syntax: weakMap.get(key);Parameters: It accepts a parameter "key" which is the key of the element which is going to be returned from the object weakmap. Return values 2 min read JavaScript weakMap has() Method The Javascript weakMap.has() is an inbuilt function in JavaScript that is used to return a boolean value which indicates whether an element with a particular key is present in the weakmap object or not. Syntax: weakMap.has(key);Parameters: It accepts a parameter 'key' which is the key of the element 2 min read JavaScript weakMap set() Method The weakMap.set() is an inbuilt function in JavaScript which is used to set a new element with a particular key and value to a WeakMap object. Syntax: weakMap.set(key, value); Parameters: It takes parameters "key" which is the key of the element which is to set to the WeakMap object and parameter "v 2 min read Like