Here's a handy trick if you need to store a lot of information in a small object.

Consider the following JS object:

var dates = { "2009": { "4": [20, 21] } };

It can be accessed like an array, dates[2009][4], yet it doesn't require 2000 elements. Neat, huh?

This is especially useful when you have to describe a few specific values (say, the date of Easter) from a big collection (say, all dates in the 1970 - 2030 range).

Become a better front-end developer!

Get updates on new posts that will help your work.

Back to Overview