Skip to content

Proper date comparison in #JavaScript

If you want to check if some variable contains valid date in JavaScript, this is the way that works properly in all cases: isValidDate: function(d) { if ( === “[object Date]” ) { // it is a date, but still it could be ‘Invalid date’ which could make trouble if ( isNaN( d.getTime() ) ) { // date is not valid return false; } else { // date is valid return true; } } else { // not a date return false; } }

Computer programming is an art

Computer programming is an art, because it applies accumulated knowledge to the world, because it requires skill and ingenuity, and especially because it produces objects of beauty. A programmer who subconsciously views himself as an artist will enjoy what he does and will do it better. Donald Knuth