Wednesday, February 4, 2026
HomeLanguagesJavascriptUnderscore.js _.isDate() function

Underscore.js _.isDate() function

Underscore.js is a javascript library that is capable enough to handle arrays, strings, objects, map, set very easily and efficiently. The _.isDate() function in underscore.js is used to tell if the given object is a date object or not. 

Syntax: 

_.isDate(object);

Parameters: It takes only one parameter i.e the object.

Return: This function returns a boolean value. The value is true is the object is date object else it is false.

Note: Please Link the underscore CDN before using this code directly in the browser through the code.

Example 1: 




<!DOCTYPE html> 
<html
  <head
    <script src =  
    </script
   </head
  <body>
    <script>
      let date=new Date()
      let str="9/9/9";
      console.log(_.isDate(date));
      console.log(_.isDate(str));
    </script>
  </body
</html>


Output:

Example 2: 




<!DOCTYPE html> 
<html
  <head
    <script src =  
    </script
   </head
  <body>
    <script>
      let date1=new Date();
      let date2="09-jan-1888"
      let boolDate1=_.isDate(date1);
      let boolDate2=_.isDate(date2);
      if(boolDate1)
      console.log(
`_.isDate function returns ${boolDate1} \n date is:  ${date1}`)
      else
      console.log(
`_.isDate function returns ${boolDate1} 
\n ${data1} is not a date object`)
      if(boolDate2)
      console.log(
`_.isDate function returns ${boolDate2} \n date is ${date2}`)
      else
      console.log(
`_.isDate function returns ${boolDate2} 
\n ${date2} is not a date object`)
    </script>
  </body
</html>


Output: 

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32478 POSTS0 COMMENTS
Milvus
125 POSTS0 COMMENTS
Nango Kala
6849 POSTS0 COMMENTS
Nicole Veronica
11980 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12066 POSTS0 COMMENTS
Shaida Kate Naidoo
6987 POSTS0 COMMENTS
Ted Musemwa
7222 POSTS0 COMMENTS
Thapelo Manthata
6935 POSTS0 COMMENTS
Umr Jansen
6919 POSTS0 COMMENTS