A way closest to your idea would be to use Array.forEach() which accepts a closure function which will be executed for each element of the array.
myArray.forEach( (item) => { // Do something console.log(item); } ); Another viable way would be to use Array.map() which works in the same way, but it also modifies each elementtakes all values that you return and returns it (resultingthem in a new array (essentially mapping each element to a new one), like this:
var myArray = [1, 2, 3]; myArray = myArray.map( (item) => { return item + 1; } ); console.log(myArray); // [2, 3, 4]