r/javascript • • May 28 '19

What are some JavaScript things beginners don't know?

333 Upvotes

383 comments sorted by

View all comments

Show parent comments

47

u/inu-no-policemen May 28 '19

This allows you to use the month as an index:

> ['jan', 'feb', 'mar', 'apr', 'may', 'etc'][new Date().getMonth()]
"may"

It probably sounded like a good idea at the time.

Anyhow, that's why it is that way. This behavior isn't unique to JS either.

44

u/NotSamNub May 28 '19

Ah, out of the 6 months in the year, my favourite has to be "etc", such lovely weather during that time of year!

0

u/[deleted] May 28 '19

[deleted]