Lodash _.isDate() Method
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
// Defining Lodash variable const _ = require( 'lodash' ); let val = new Date; // Checking for Date Object 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
// Defining Lodash variable const _ = require( 'lodash' ); let val = "15/07/2020" ; // Checking for Date Object 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.
Contact Us