Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

typeof Date javascript

let x = new Date();
if (x instanceof Date) {
  // will execute
}

let x = new Date();
if (Object.prototype.toString.call(x) === "[object Date]") {
  // will execute
}

let x = new Date("Bad String");
if (x instanceof Date) {
  // executes, because `x` is technically a date object
}
if (x instanceof Date && !isNaN(x)) {
  // will not execute
}
 
PREVIOUS NEXT
Tagged: #typeof #Date #javascript
ADD COMMENT
Topic
Name
1+3 =