Javascript does not feature associative arrays. However, you can create something similar using object arrays.
Example:
This array can be accessed with:
Values can be added or changes:
More info here: http://www.i-programmer.info/programming/javascript/1441-javascript-data-structures-the-associative-array.html
You can iterate over the object array using Jquery:
Example:
arr={'key1': 'value1','key2':'value2'};
This array can be accessed with:
the_value = array['key2']
Values can be added or changes:
arr['key3']='value3';
More info here: http://www.i-programmer.info/programming/javascript/1441-javascript-data-structures-the-associative-array.html
You can iterate over the object array using Jquery:
$.each( arr, function( index, value ){
sum += value;
});
No comments:
Post a Comment