1/* new options with IE6: loop through array of objects */
2
3const people = [
4 {id: 100, name: 'Vikash'},
5 {id: 101, name: 'Sugam'},
6 {id: 102, name: 'Ashish'}
7];
8
9// using for of
10for (let persone of people) {
11 console.log(persone.id + ': ' + persone.name);
12}
13
14// using forEach(...)
15people.forEach(person => {
16 console.log(persone.id + ': ' + persone.name);
17});
18// output of above two methods
19// 100: Vikash
20// 101: Sugam
21// 102: Ashish
22
23
24// forEach(...) with index
25people.forEach((person, index) => {
26 console.log(index + ': ' + persone.name);
27});
28// output of above code in console
29// 0: Vikash
30// 1: Sugam
31// 2: Ashish
32
1yourArray.forEach(function (arrayItem) {
2 var x = arrayItem.prop1 + 2;
3 console.log(x);
4});