Created
April 13, 2017 02:22
-
-
Save bambooom/08fb3933788b21a572686f241b115f1d to your computer and use it in GitHub Desktop.
when variable s is null or undefined, what is Date(s) ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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