Lodash _.isDate() Method

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

Syntax:

_.isDate( Value )

Parameters: This method accepts a single parameter as mentioned above and described below:

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




// Defining Lodash variable
const _ = require('lodash'); 
     
var val = new Date;
// Checking for Date Object
console.log("The Value is Date : " 
            +_.isDate(val));


Output:

The Value is Date : true

Example 2: The following example returns false as the value is a string object, not a date object.




// Defining Lodash variable
const _ = require('lodash'); 
     
var 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. 

Lodash library can be installed using npm install lodash.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also
Close
Back to top button