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:
- value: This parameter holds the value to check.
Return Value:
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
const _ = require( 'lodash' );
let obj = new Array(2);
obj.fill(5)
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
const _ = require( 'lodash' );
console.log(_.isWeakMap( new WeakMap));
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
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!