[javascript] Detecting an "invalid date" Date instance in JavaScript