Open In App

Node.js util.types.isSymbolObject() Method

Last Updated : 27 Apr, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The util.types.isSymbolObject() method is an inbuilt application programming interface of the util module which is primarily designed to support the needs of Node.js own internal APIs. The util.types.isSymbolObject() method is used to determine whether the value is a symbol object. 

Syntax:

util.types.isSymbolObject( value )

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

Return value: It returns a Boolean value i.e. returns true only if the value is a symbol object otherwise it returns false

Note: A symbol object is created by calling Object() on a symbol primitive. 

The below examples illustrate the use of util.types.isSymbolObject() method in Node.js.

Example 1: 

javascript




// Node.js program to demonstrate the
// util.types.isSymbolObject() method
 
// Using require to access util module
const util = require('util');
 
// Using util.types.isSymbolObject() method
console.log(util.types.isSymbolObject(new Map()));
 
// Using util.types.isSymbolObject() method
console.log(util.types.isSymbolObject(Object({'geeks': 1})));
 
// Using util.types.isSymbolObject() method
console.log(util.types.isSymbolObject(Object(Symbol('geeks'))));


Output:

false
false
true

Example 2: 

javascript




// Node.js program to demonstrate the
// util.types.isSymbolObject() method
 
// Using require to access util module
const util = require('util');
 
// Using util.types.isSymbolObject() method
console.log(util.types.isSymbolObject(new Map()));
 
// Creating a symbol
const symbol = Symbol('GeeksforGeeks');
 
// Using util.types.isSymbolObject() method
console.log(util.types.isSymbolObject(symbol));
 
 
// Using util.types.isSymbolObject() method
console.log(util.types.isSymbolObject(Object(symbol)));


Output:

false
false
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_issymbolobject_value



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads