foreach indexed array js code example
Example 1: js loop through associative array
var months = [];
months["jan"] = "January";
months["feb"] = "February";
months["mar"] = "march";
for (var key in months) {
var value = months[key];
console.log(key, value);
}
Example 2: foreach javascript
var items = ["item1", "item2", "item3"]
var copie = [];
items.forEach(function(item){
copie.push(item);
});