Skip to content

Check if a variable is a date in JavaScript?

We can use these code snippets to determine if a variable is a date in JavaScript.


let d = new Date();
console.log(d instanceof Date)

let d = new Date();
console.log( === "[object Date]")
See also  How to remove an element from an array in JavaScript?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.