Node.js util.types.isSymbolObject() Method
Last Updated :
27 Apr, 2023
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
const util = require( 'util' );
console.log(util.types.isSymbolObject( new Map()));
console.log(util.types.isSymbolObject(Object({ 'geeks' : 1})));
console.log(util.types.isSymbolObject(Object(Symbol( 'geeks' ))));
|
Output:
false
false
true
Example 2:
javascript
const util = require( 'util' );
console.log(util.types.isSymbolObject( new Map()));
const symbol = Symbol( 'GeeksforGeeks' );
console.log(util.types.isSymbolObject(symbol));
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
Share your thoughts in the comments
Please Login to comment...