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"
Written by Mariz Melo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Related Tags
#javascript
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#