Skip to content
Related Articles

Related Articles

Node.js | util.types.isSetIterator() Method
  • Last Updated : 21 Jan, 2020

The util.types.isSetIterator() method is an inbuilt application programming interface of util module which is primarily designed to support the needs of Node.js own internal APIs.

The util.types.isSetIterator() method is used to determine whether the value is an iterator returned for a built-in set instance.

Syntax:

util.types.isSetIterator( value )

Parameter: This method accepts a single parameters value which holds any valid JavaScript data types like Boolean, Null, Number, Object, etc.

Return value: It returns a Boolean value i.e returns true if value is an iterator returned for a built-in Set instance otherwise it is false.



Below examples illustrate the use of util.types.isSetIterator() method in Node.js:

Example 1:




// Node.js program to demonstrate the 
// util.types.isSetIterator() method 
  
// Using require to access util module 
const util = require('util');
  
// Using util.types.isSetIterator() method
console.log(util.types.isSetIterator(true));
  
// Using util.types.isSetIterator() method
console.log(util.types.isSetIterator(new Set().values()));
  
// Using util.types.isSetIterator() method
console.log(util.types.isSetIterator(new Set().keys()));

Output:

false
true
true

Example 2:




// Node.js program to demonstrate the 
// util.types.isSetIterator() method 
  
// Using require to access util module 
const util = require('util');
  
const set = new Set();
  
// Using util.types.isSetIterator() method
console.log(util.types.isSetIterator(set.keys()));
  
// Using util.types.isSetIterator() method
console.log(util.types.isSetIterator(set.entries()));
  
// Using util.types.isSetIterator() method
console.log(util.types.isSetIterator(set[Symbol.iterator]()));

Output:

true
true
true

Note: The above program will compile and run by using the node index.js command.

Reference: https://nodejs.org/dist/latest-v13.x/docs/api/util.html#util_util_types_issetiterator_value

My Personal Notes arrow_drop_up
Recommended Articles
Page :