Node.js util.types.isSet() Method
Last Updated :
04 Apr, 2023
The util.types.isSet() method of the util module is primarily designed to support the needs of Node.js own Internal APIs. It is used to check whether the passed instance in the method is a built-in Set instance or not.
Syntax:
util.types.isSet( value )
Parameters: This method accepts a single parameter value that holds any value i.e instance of any module.
Return value: This method returns a Boolean value i.e true if the passed value is a built-in instance of Set otherwise returns false.
The below examples illustrate the use of util.types.isSet() method in Node.js:
Example 1:
javascript
const util = require( 'util' );
console.log(util.types.isSet( new Set()));
console.log(util.types.isSet( new Map()));
|
Output:
true
false
Example 2:
javascript
const util = require( 'util' );
const set1 = new Set( "geeksforgeeks" );
console.log(util.types.isSet(set1));
const numbers = [2, 3, 4, 4, 2, 3, 3, 4,
4, 5, 5, 6, 6, 7, 5, 32, 3, 4, 5];
const set2 = new Set(numbers);
console.log(util.types.isSet(set2));
console.log(util.types.isSet( new Map()));
|
Output:
true
true
false
Reference: https://nodejs.org/api/util.html#util_util_types_isset_value
Share your thoughts in the comments
Please Login to comment...