Node.js util.types.isSet() Method
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
// Node.js program to demonstrate the // util.types.isSet() method // It includes util module const util = require( 'util' ); // Return true as passed instance is of Set console.log(util.types.isSet( new Set())); // Return false as passed instance is of Map console.log(util.types.isSet( new Map())); |
Output:
true false
Example 2:
javascript
// Node.js program to demonstrate the // util.types.isSet() method // It includes util module const util = require( 'util' ); // Making a set object of a string const set1 = new Set( "w3wiki" ); // Return true as passed instance is of Set 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]; // Making a set object of array const set2 = new Set(numbers); // Return true as passed instance is of Set console.log(util.types.isSet(set2)); // Return false as passed instance is of Map console.log(util.types.isSet( new Map())); |
Output:
true true false
Reference: https://nodejs.org/api/util.html#util_util_types_isset_value
Contact Us