Lodash _.isDate() Method
Last Updated :
27 Oct, 2023
Lodash _.isDate() method Checks if the given value can be classified as a Date Object or not.
Syntax:
_.isDate(Value);
Parameters:
- Value: This parameter holds the value that needs to be Checked for Date Object.
Return Value:
This method returns a Boolean value(Returns true if the given value is a Date Object, else false).
Example 1: In this example, the lodash .isDate() method is returning true as the given value is a date object.
javascript
const _ = require( 'lodash' );
let val = new Date;
console.log( "The Value is Date : "
+ _.isDate(val));
|
Output:
The Value is Date : true
Example 2: In this example, the lodash .isDate() method is returning false as the given value is a string.
javascript
const _ = require( 'lodash' );
let val = "15/07/2020" ;
console.log( "The Value is Date : "
+ _.isDate(val));
|
Output:
The Value is Date : false
Note: This will not work in normal JavaScript because it requires the lodash library to be installed.
Share your thoughts in the comments
Please Login to comment...