javascript es6 foreach code example

Example 1: es6 forEach

const array1 = ['a', 'b', 'c'];

array1.forEach((element) => {
  console.log(element)
});

// expected output: "a"
// expected output: "b"
// expected output: "c"

Example 2: foreach jas

const array1 = ['a', 'b', 'c'];

array1.forEach(element => console.log(element));

Example 3: js for each item do

let array = ['Item 1', 'Item 2', 'Item 3'];

array.forEach(item => {
	console.log(item); // Logs each 'Item #'
});

Example 4: mdn foreach

arr.forEach(callback(currentValue [, index [, array]])[, thisArg])

Example 5: es6 foreach dom element

//es6
Array.from(els).forEach((el) => {
});

//old shit
Array.prototype.forEach.call(els, function(el) {
    // Do stuff here
    console.log(el.tagName);
});

// Or
[].forEach.call(els, function (el) {...});

Example 6: foreach javascript

arr.forEach(callback(currentValue [, index [, array]])[, thisArg]);