Skip to content
Related Articles

Related Articles

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

The util.types.isSymbolObject() 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.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 which 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 value is a a symbol object otherwise it returns false.



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

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

Example 1:




// 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:




// 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

My Personal Notes arrow_drop_up
Recommended Articles
Page :