Perl Like Hashes

[Total: 0    Average: 0/5]

This shows how to have perl like hashes in javascript.

Body Code:

<script>
var myArray=new Array();
  myArray["thisvalue"]=12;
  myArray["thatvalue"]=14;

// -or-
var thisvalue=0;
var thatvalue=1;
  myArray[thisvalue]=8;
  myArray[thatvalue]=10;

// then you can show all the items by:
for(var i in myArray)
document.write(i+"="+myArray[i]+"<BR>");
</script>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *