Last Updated: February 25, 2016
·
1.13K
· jmarizgit

JavaScript Dates - Month weirdness

Another pearl from JavaScript is the odd use of index 0 to express January in dates, try yourself:

var month = new Date(2013, 0, 31)
> Thu Jan 31 2013 00:00:00 GMT-0800 (PST)  

Notice I have used "0" to express "January". Is the same way you use to get the first element in a Array.

var arr = new Array("January", "February", "March", "April")
arr[0]
> "January"