Closed
Description
Bug Report
π Search Terms
date constructor month
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about naming conventions
β― Playground Link
Playground link with relevant code
π» Code
// this is May 2022
new Date(2022, 4)
π Actual behavior
The date constructor documentation gives no indication that the month
parameter is zero index based (January is month 0, February is month 1). This can cause off-by-one error bugs that are hard to detect.
π Expected behavior
I expected the documentation to be clear about the type of value expected in the constructor. For example:
- rename
month
parameter tomonthIndex
(MDN also usesmonthIndex
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#syntax) - add JSDoc for the constructor explaining the month parameter