1let date1 = new Date();
2let date2 = new Date("random string");
3
4(Object.prototype.toString.call(date1) === '[object Date]' && date1 != "Invalid Date") // true
5(Object.prototype.toString.call(date2) === '[object Date]' && date2 != "Invalid Date") // false
1//checks if is object, null val returns false
2function isObject(val) {
3 if (val === null) { return false;}
4 return ( (typeof val === 'function') || (typeof val === 'object') );
5}
6var person = {"name":"Boby Snark"};
7isObject(person);//true