I'm so confuse with this: Date(2017, 0, 0).getDate() // 31 Date(2017,1,0).getDate() // 31 ???? Date(2017,2,0).getDate() // 28 ???? Someone please explain.
From what I can see, the Date() constructor returns 31 when initialized with invalid arguments. However, if it can resolve the arguments for year and month, the getDate() method will return the number of days in that month. It also appears that the parameters are not using zero based indexes to specify month and day. Therefore, any lines specifying 0 for month will yield 31. The lines that specify 1 or 2 for month and 0 for days yields the number of days in January and February, respectively.
Thanks for that David. Sam, JS Month is 0-based, but thanks anyway :)