Loop and Iterate through Arrays and Dictionaries in JavaScript.
Use the ForEach
function to loop through arrays.
var array = [...];
ForEach(array, function(index, value) {
console.log('The value: ' + value + ' is at index: ' + index);
});
Use the Iterate
function to iterate through dictionaries.
var dict = {...};
Iterate(dict, function(key, value) {
console.log('The value: ' + value + ' is at key: ' + key);
});