<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JavaScript associative array access</title>
</head>
<body>
<pre>
<script type="text/javascript">
var normalArray= new Array();
normalArray[0] = ".com";
normalArray[1] = ".net";
normalArray[2] = ".org";
normalArray[3] = ".gov";
document.writeln("Length: " + normalArray.length);
// Outputs 4, array length
var associativeArray = new Array();
associativeArray['commercial'] = ".com";
associativeArray['network'] = ".net";
associativeArray['organization'] = ".org";
associativeArray['government'] = ".gov";
document.writeln("Length: " + associativeArray.length);
// Outputs 0, array length
document.writeln("commercial domain: " + associativeArray['commercial']);
document.writeln("commercial domain: " + associativeArray.commercial);
</script>
</pre>
</body>
</html>