Underscore.js _.isDate() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Object

Definition

Returns true if object is a Date (official Underscore docs). ISO strings, timestamps, and plain objects return false.

Pass the required arguments shown below. Underscore object helpers usually return a new value — check whether the source object is mutated.

Syntax

Call _.isDate. Start with this line.

Underscore
_.isDate(object)
CallWhat it does
_.isDate(object)Primary signature.
_.isDate(...)Call with the arguments your case needs.

Load Underscore with import _ from "underscore" (or the UMD CDN build) so these helpers are available as _.

Library declarations
Underscore
_.isDate(object)

Parameters

ParameterDescription
objectRequired. Value to test

Return Value

Return ValueDescription
*true or false

Underscore.js Examples

Example 1 — Official Docs

The docs show a real Date passing and an ISO string failing.

Underscore
_.isDate(new Date());
// → true

_.isDate("2026-08-17");
// → false
Try It Yourself

How It Works

  1. Create a Date. new Date() builds a Date object.
  2. Check it. _.isDate(…) → true.
  3. ISO string. Looks like a date but is still a string → false.
  4. Takeaway. The helper checks the type, not the text format.

Example 2 — Numbers Are Not Dates

Timestamps are numbers. Wrap them with new Date(ms) first.

Underscore
console.log(_.isDate(new Date()));  // true
console.log(_.isDate(100));         // false
console.log(_.isDate(Date.now()));  // false
Try It Yourself

How It Works

  1. Date object. Passes the type check.
  2. Plain number. 100 is not a Date → false.
  3. Date.now(). Returns milliseconds (a number) → false.
  4. Convert. Use new Date(Date.now()) when you need a Date.

Example 3 — Strings vs Parsed Dates

Date-looking strings fail until you parse them.

Underscore
console.log(_.isDate("Mon Aug 17 2026"));            // false
console.log(_.isDate(new Date("Mon Aug 17 2026")));  // true
console.log(_.isDate({}));                           // false
Try It Yourself

How It Works

  1. String text. Still a string → fails.
  2. Parse it. new Date(…) builds a Date object → passes.
  3. Plain object. {} is not a Date → fails.
  4. Rule. Parse first, then call _.isDate.

Example 4 — Invalid Date Still Passes

isDate is a type check. Use getTime() for validity.

Underscore
var bad = new Date("not a date");

console.log(_.isDate(bad));        // true
console.log(isNaN(bad.getTime())); // true
Try It Yourself

How It Works

  1. Bad parse. Still creates a Date object (Invalid Date).
  2. Type check. _.isDate(bad) → true.
  3. Validity. getTime() is NaN for Invalid Date.
  4. Pair them. Use _.isDate(d) && !isNaN(d.getTime()) for a real instant.

Browser & Runtime Support

_.isDate ships with Underscore.js (1.x). It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore.

✓ Stable · Underscore 1.x

_.isDate()

Available in [email protected] (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded.

100% With Underscore 1.x
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.isDate Underscore 1.x+

Bottom line: Safe for production once Underscore is on the page or in your bundle. Not a native browser API — load Underscore first. Prefer a pinned CDN version (e.g. [email protected]).

Frequently Asked Questions

_.isDate(object) returns true only when the value is a Date object — including Invalid Date. ISO strings, timestamps such as 100 or Date.now(), and plain objects return false.
_.isDate(new Date()) returns true. The docs pick a real Date instance on purpose: that is the type the helper looks for.
No. "2026-08-17" is still a string. Parse it with new Date(...) first if you need a Date object, then call isDate on the result.
Yes. new Date("not a date") is still a Date object, so isDate is true. Pair it with isNaN(d.getTime()) when you need a real calendar instant.
typeof new Date() is "object", so typeof is too broad. instanceof Date usually agrees in the same window. Underscore uses the [object Date] tag, which is more consistent across iframes than instanceof.
No. It is a stable Underscore 1.x helper used to decide whether a value is a Date before you call getTime, toISOString, or other Date methods.

Next: _.isRegExp()

Test whether a value is a regular expression — another core Underscore type check.

_.isRegExp() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful