Javascript Date check if a defined variable is a date
let a = new Date(); let b = 3.14; /*w w w. j a va2 s.c o m*/ let c = "I'm a string"; if (a instanceof Date) { console.log("a is a Date"); } else { console.log("a is not a Date"); } if (b instanceof Date) { console.log("b is a Date"); } else { console.log("b is not a Date"); } if (c instanceof Date) { console.log("c is a Date"); } else { console.log("c is not a Date"); }