Why does the month argument range from 0 to 11 in JavaScript's Date constructor?

后端 未结 8 1186
生来不讨喜
生来不讨喜 2020-11-22 15:31

When initializing a new Date object in JavaScript using the below call, I found out that the month argument counts starting from zero.

new Date(         


        
8条回答
  •  清歌不尽
    2020-11-22 15:52

    Everything but the day of the month is 0 based, see here for a full list including ranges :)

    It's actually the 1 based days that are the oddballs here...oddly enough. Why was this was done? I don't know...but probably happened the same meeting they got plastered and decided semicolons were optional.

提交回复
热议问题