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.
[php]
<!DOCTYPE html>
<html>
<body>

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

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

</body>
</html>

[/php]
OUTPUT :



Leave a Reply