JavaScript weakMap has() Method Last Updated : 07 Aug, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 which is going to be tested for presence in the object weakmap. Return values: It returns true if the element with the specified key is present in the weakmap object otherwise it returns false. Below are examples of weakMap.has() method. Example 1: Below is a basic example of weakmap.has() method that returns true. javascript function gfg() { const weakmap = new WeakMap(); const key = {}; weakmap.set(key, 'gfg'); console.log(weakmap.has(key)); } gfg(); OutputtrueExample 2: Here the output is false because the key "key1" has not been set at the end of the weakMap object. javascript // Creating a WeakMap() object const weakmap1 = new WeakMap(); // Creating a key "key1" const key1 = {}; // Testing whether the key is present // in the weakMap() object or not console.log(weakmap1.has(key1)); OutputfalseWe have a complete list of Javascript WeakMap methods, to check those please go through Javascript WeakMap Complete reference article. Supported Browsers: Google Chrome 36 and aboveEdge 12 and aboveFirefox 6 and aboveInternet Explorer 11 and aboveOpera 23 and aboveSafari 8 and above Comment More infoAdvertise with us Next Article JavaScript weakMap set() 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