Lodash _.isSet() Method
Last Updated :
13 Nov, 2023
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.
Javascript
const _ = require( "lodash" );
var obj= new Array(2);
obj.fill(10);
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.
Javascript
const _ = require( "lodash" );
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.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...