[javascript] Loop through array of values with Arrow Function

Lets say I have:

var someValues = [1, 'abc', 3, 'sss'];

How can I use an arrow function to loop through each and perform an operation on each value?

This question is related to javascript ecmascript-6

The answer is


One statement can be written as such:

someValues.forEach(x => console.log(x));

or multiple statements can be enclosed in {} like this:

someValues.forEach(x => { let a = 2 + x; console.log(a); });