Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Node.js util.types.isModuleNamespaceObject() Method

  • Last Updated : 13 Aug, 2020

This function is used to check whether the following object is an instance of Module Namespace Object. This function returns a true value if the value is an instance of a Module Namespace Object.

Syntax:

util.types.isModuleNamespaceObject( value ); 

Parameters:

  • value: This value parameter is of any type. It is the value for which the function is to be checked for.

Return value: This function returns Boolean value. It returns True or false depending on whether an object is a Module Namespace Object or not.

Example 1: Filename: index.js




// Requiring module
const util = require('util');
const mongoose = require('mongoose')
  
console.log(util.types.isModuleNamespaceObject(mongoose))
console.log(util.types.isModuleNamespaceObject(util))

Output:

false
false

Example 2: Filename: index.js




// Requiring file
const b = require('./index.js');
// The index.js can be anyfile located in 
// the directory where the code resides
  
// Requiring module
const util = require('util')
  
if (util.types.isModuleNamespaceObject(b)) {
   console.log("It is a namespaceobject module")
} else {
   console.log("It is not a namespace object module")
}

Run index.js file using the following command:

node index.js

Output:

It is not a namespaceobject module

Reference: https://nodejs.org/api/util.html#util_util_types_ismodulenamespaceobject_value

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!