Here's a similar answer using using a =>
style function:
var data = [1,2,3,4];
data.forEach( (item, i, self) => self[i] = item + 10 );
gives the result:
[11,12,13,14]
The self
parameter isn't strictly necessary with the arrow style function, so
data.forEach( (item,i) => data[i] = item + 10);
also works.