Last Updated : 03 Nov, 2023
Lodash _.isWeakMap() method is used to find whether the given value is a weakmap object or not. It returns True if the given value is a weakmap object. Otherwise, it returns false.
Syntax:_.isWeakMap(value);Parameters:
This method returns true if the value is a weakmap, else false.
Example 1: In this example, we are checking whether the given value is weakMap or not and printing the result in the console.
javascript
// Requiring the lodash library
const _ = require('lodash');
// Creating a array of size 2
// using constructor
let obj = new Array(2);
// Filling value 5 in the array
obj.fill(5)
// Use of _.isWeakMap() method
console.log(_.isWeakMap(obj));
Output:
false
Example 2: In this example, we are checking whether the given value is weakMap or not and printing the result in the console.
javascript
// Requiring the lodash library
const _ = require('lodash');
// Use of _.isWeakMap() method
// When a weak set is given
console.log(_.isWeakMap(new WeakMap));
// When a weak set is not given
console.log(_.isWeakMap(new Map));
Output:
true false
Note: This will not work in normal JavaScript because it requires the library lodash to be installed.
Reference: https://lodash.com/docs/4.17.15#isWeakMap
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4