Open In App

Node.js util.types.isMap() Method

Improve
Improve
Like Article
Like
Save
Share
Report

The util.types.isMap() 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.isMap() method is used to determine whether the value is a built-in Map instance or not.

Syntax:

util.types.isMap( value )

Parameters: This method accepts a single parameter 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 instance of built-in Map otherwise it returns false.

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

Example 1:




// Node.js program to demonstrate the 
// util.types.isMap() method 
  
// Using require to access util module 
const util = require('util');
  
// Using util.types.isMap() method
console.log(util.types.isMap(1));
  
// Using util.types.isMap() method
console.log(util.types.isMap("Map"));
  
// Using util.types.isMap() method
console.log(util.types.isMap(new Map()));


Output:

false
false
true

Example 2:




// Node.js program to demonstrate the 
// util.types.isMap() method 
  
// Using require to access util module 
const util = require('util');
  
// Creating a Map variable
const map = new Map();
  
// Entering values in Map
map.set("geeks", "Computer science");
  
map.set("Hello", "World");
  
// Creating a String type variable
const text = "GeeksforGeeks";
  
// Using util.types.isMap() method
console.log(util.types.isMap(map));
  
// Using util.types.isMap() method
console.log(util.types.isMap(text));
  
// Using util.types.isMap() method
console.log(util.types.isMap());


Output:

true
false
false

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_ismap_value



Last Updated : 13 Oct, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads