Skip to content

Instantly share code, notes, and snippets.

@bambooom
Created April 13, 2017 02:22
Show Gist options
  • Save bambooom/08fb3933788b21a572686f241b115f1d to your computer and use it in GitHub Desktop.
Save bambooom/08fb3933788b21a572686f241b115f1d to your computer and use it in GitHub Desktop.
when variable s is null or undefined, what is Date(s) ?
var s;
// s is undefined
new Date(s)
// -> Invalid date
new Date(s) < new Date()
// -> false
var s = null;
// s is null
new Date(s)
// -> Thu Jan 01 1970 08:00:00 GMT+0800 (HKT)
// i.e. the starting time of unix
new Date(s) < new Date()
// -> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment