In Association with Amazon.in   Flipkart

Tuesday, September 10, 2013

JavaScript Associative Array WIth Example

JavaScript Associative Array: An array with Index/Keys as String. In Each array element we can store two values. In index one value and in array of index another value.


Example:
<script>

 a=new Array(4);
a['rno']=1234;
a['name']="Raju";
a['job']="Manager";
a['sal']=35000;

document.write(a['name']);          //  Raju


 // To Print All Associative Array Elements

 for(i in a) {
 document.write("<br/>" +  i + " =========> " + a[i]);
}

</script>

output:

Raju
rno =========> 1234
name =========> Raju
job =========> Manager
sal =========> 35000



No comments:

Post a Comment


Related Posts Plugin for WordPress, Blogger...