js check if date code example
Example 1: javascript detect if object is date
var myDate=new Date();
if(myDate instanceof Date){
}
Example 2: javascript check if date object
let date1 = new Date();
let date2 = new Date("random string");
(Object.prototype.toString.call(date1) === '[object Date]' && date1 != "Invalid Date")
(Object.prototype.toString.call(date2) === '[object Date]' && date2 != "Invalid Date")
Example 3: javascript check if variable is object
function isObject(val) {
if (val === null) { return false;}
return ( (typeof val === 'function') || (typeof val === 'object') );
}
var person = {"name":"Boby Snark"};
isObject(person);