Open In App

Lodash _.isDate() Method

Lodash _.isDate() method Checks if the given value can be classified as a Date Object or not. 

Syntax:

_.isDate(Value);

Parameters:

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 : true

Example 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 : false

Note: This will not work in normal JavaScript because it requires the lodash library to be installed. 

Article Tags :