Node.js util.types.isDate() Method
Last Updated :
31 Mar, 2023
The util.types.isDate() method is an inbuilt application programming interface of the util module which is used to check the type for Date in the node.js.
Syntax:
util.types.isDate( value )
Parameters: This method accepts a single parameter as mentioned above and described below.
- value: It is a required parameter of any datatype.
Return Value: This returns a boolean value, TRUE if the value is a Date object, FALSE otherwise.
Example 1: The below example illustrates the use of util.types.isDate() method in Node.js:
javascript
const util = require( 'util' );
let v1 = new Date();
let v2 = 3 / 6 / 96;
console.log(util.types.isDate(v1));
console.log(util.types.isDate(v2));
|
Output:
true
false
Example 2: In this example, we will illustrate the use of util.types.isDate() method in Node.js
javascript
const util = require( 'util' );
let v1 = new Date();
let v2 = 3 / 6 / 96;
if (util.types.isDate(v1))
console.log( "The passed value is a Date." );
else
console.log( "The passed value is not a Date" );
if (util.types.isDate(v2))
console.log( "The passed value is a Date." );
else
console.log( "The passed value is not a Date" );
|
Output:
The passed value is a Date.
The passed value is not a Date
Note: The above program will compile and run by using the node filename.js command.
Reference: https://nodejs.org/api/util.html#util_util_types_isdate_value
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...