I need to verify is var is valid datetime object. This
alert( "dat::"+( typeof dat ))
returns "object". Which is the valid way ?
I need to verify is var is valid datetime object. This
alert( "dat::"+( typeof dat ))
returns "object". Which is the valid way ?
Here is how I would do it:
if ( Object.prototype.toString.call(d) === "[object Date]" ) {
// it is a date
}
else {
// not a date
}
Use instanceof:
dat instanceof Date
[[Prototype]] chain. That doesn't happen across frames since different Date constructors (and hence Date.prototype objects) are used.