Associative Arrays in JavaScript

There are many programming languages which supports array with named indexes and known as Associative arrays or hashes. But JavaScript does not support arrays with named indexes because they are used as numbered indexers.
<!DOCTYPE html>

<p id="demo"></p>

var person = [];
person[0] = "Suraj";
person[1] = "Singh";
person[2] = 26;
document.getElementById("demo").innerHTML =
person[0] + " " + person.length;



Leave a Reply