Follow this Blog!

Aug 15, 2016

Amazon If you use Javascript, you may be wondering how to create a Javascript map whose value is an Array of keys and values. Although Javascript does not support map, we can use a simple way to simulate a map. Here's how you do it.

First create a Javascript Object.

var dateMap={};

or

var dateMap = new Object();

Personally I like the former for its simplicity in syntax.

Next you fill this map with keys and their corresponding Array value.

In my example, the key of the map is a date, and its value is an array containing a set of information about this date. Here's the Javascript code: