which array method is similar to forEach code example
Example 1: js for each item do
let array = ['Item 1', 'Item 2', 'Item 3'];
array.forEach(item => {
console.log(item);
});
Example 2: javascript .foreach
let colors = ['red', 'blue', 'green'];
colors.forEach(function(color, idx, sourceArr) {
console.log(color, idx, sourceArr)
});
Example 3: foreach javascript
let names = ['josh', 'joe', 'ben', 'dylan'];
names.forEach((name, index, sourceArr) => {
console.log(color, idx, sourceArr)
});
Example 4: mdn foreach
arr.forEach(callback(currentValue [, index [, array]])[, thisArg])