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 convert JavaScript Array to comma separated string?

Leave a Reply

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

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