Lodash _.isSet() method is used to find whether the given value is classified as a Set object or not. It returns True if the given value is a set. Otherwise, it returns false.
Syntax:
_.isSet(value)
Parameters:
This method accepts a single parameter as mentioned above and described below:
- value: This parameter holds the value to check.
Return Value:
This method returns true if the value is a set, else false.
Example 1: In this example, the code creates an array of size 2, fills it with the value 10, and then checks if the array is a Set object using the _.isSet()
method.
Here, const _ = require(‘lodash’) is used to import the lodash library into the file.
// Requiring the lodash library const _ = require( "lodash" );
// Creating a array of size 2 var obj= new Array(2);
// Filling array with value 10 obj.fill(10); // Use of _.isSet() method console.log(_.isSet(obj)); |
Output:
false
Example 2: In this example, the code uses the Lodash library to check whether the given values are Set objects using the _.isSet()
method.
// Requiring the lodash library const _ = require( "lodash" );
// Use of _.isSet() method console.log(_.isSet( new Set));
console.log(_.isSet( new WeakSet));
|
Output:
true
false
Note: This code will not work in normal JavaScript because it requires the library lodash to be installed.