What is Associative Array?

An associative array is simply a set of key value pairs. When we define an object, JavaScript automatically creates an array for this object. This allows us to refer to the data indices using strings.
which is the same as color.red .

Associative arrays as objects

The key idea is that every Javascript object is an associative array which is the most general sort of array you can invent sometimes this is called a hash or map structure or a dictionary object. An associative array is declared or dynamically created. We can create it by assigning a literal to a variable.
var colArr = { "red": 1, "blue": 2, "green": 3 };
Unlike simple arrays, we use curly braces instead of square brackets. Also, the content is accessed by keys, whatever the method used to declare the array.
var c = colArr["red"];