The util.types.isMapIterator() method is an inbuilt application programming interface of util module which is primarily designed to support the needs of Node.js internal APIs.
The util.types.isMapIterator() method is used to determine whether the value is an iterator returned for a built-in Map instance or not.
Syntax:
util.types.isMapIterator( value )
Parameters: 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 Map otherwise it returns false.
Below examples illustrate the use of util.types.isMapIterator() Method in Node.js:
Example 1:
const util = require( 'util' );
console.log(util.types.isMapIterator( true ));
console.log(util.types.isMapIterator( new Map().values()));
console.log(util.types.isMapIterator( new Map().keys()));
|
Output:
false
true
true
Example 2:
const util = require( 'util' );
const map = new Map();
console.log(util.types.isMapIterator(map.keys()));
console.log(util.types.isMapIterator(map.entries()));
console.log(util.types.isMapIterator(map[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_ismapiterator_value
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
13 Oct, 2021
Like Article
Save Article