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.
// 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 : trueExample 2: In this example, the lodash .isDate() method is returning false as the given value is a string.
// 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 : falseNote: This will not work in normal JavaScript because it requires the lodash library to be installed.