Node.js util.types.isStringObject() Method
Last Updated :
04 Apr, 2023
The util.types.isStringObject() method of the util module is primarily designed to support the needs of Node.js own Internal APIs. It is used to check whether the passed instance in the method is a String object or not. There is a difference between a string primitive and a String object in javascript, string is a primitive datatype it has no methods and it is nothing more than a pointer to a raw data memory reference.
Syntax:
util.types.isStringObject( value )
Parameters: This method accepts a single parameter value that holds any value i.e instance of any module.
Return value: This method returns a Boolean value i.e true if the passed value is a string object otherwise returns false.
The below examples illustrate the use of util.types.isStringObject() method in Node.js:
Example 1:
javascript
const util = require( 'util' );
console.log(util.types.isStringObject( "geeksforgeeks" ));
console.log(util.types.isStringObject( new String()));
|
Output:
false
true
Example 2:
javascript
const util = require( 'util' );
const temp_string = "geeksforgeeks"
console.log(util.types.isStringObject(temp_string));
const s_object = new String(temp_string);
console.log(util.types.isStringObject(s_object));
console.log(util.types.isStringObject( new Set()));
|
Output:
false
true
false
Reference: https://nodejs.org/api/util.html#util_util_types_isstringobject_value
Share your thoughts in the comments
Please Login to comment...