invalid date js code example Example: dedecting invalid date in js function isValidDate(d) { return d instanceof Date && !isNaN(d); }