1const array1 = ['a', 'b', 'c'];
2
3array1.forEach((element) => {
4 console.log(element)
5});
6
7// expected output: "a"
8// expected output: "b"
9// expected output: "c"
1var sandwiches = [
2 'tuna',
3 'ham',
4 'turkey',
5 'pb&j'
6];
7
8sandwiches.forEach(function (sandwich, index) {
9 console.log(index);
10 console.log(sandwich);
11});
12
13// returns 0, "tuna", 1, "ham", 2, "turkey", 3, "pb&j"
14
1const array1 = ['a', 'b', 'c'];
2
3array1.forEach(element => console.log(element));
1let listeDePays = ['France', 'Belgique', 'Japon', 'Maroc'];
2listeDePays.forEach(pays => console.log(pays));
1//es6
2Array.from(els).forEach((el) => {
3});
4
5//old shit
6Array.prototype.forEach.call(els, function(el) {
7 // Do stuff here
8 console.log(el.tagName);
9});
10
11// Or
12[].forEach.call(els, function (el) {...});