Associative array in JavaScript
We can use associative arrays in javascript somewhat similar to PHP. Here is an example:
/* Declaring array in javascript */ var opensource = new Array(); /* assigning values to this javascript associative array */ opensource[‘cms’] = ‘Joomla’; opensource[‘forum’] = ‘phpBB’; opensource[‘blog’] = ‘Wordpress’; opensource[‘os’] = ‘Linux’; opensource[‘database’] = ‘MySQL’; opensource[‘webserver’] = ‘Apache’;
We can navigate this array as
for(script in opensource)
{
//to get the key for each index
alert(script)
//to get the value for each position
alert(opensource[script]);
}