arr.set-each

array.forEach but every value is set in the array

Usage no npm install needed!

<script type="module">
  import arrSetEach from 'https://cdn.skypack.dev/arr.set-each';
</script>

README

Array.prototype.setEach

download:

npm install arr.set-each --save

use:

require('arr.set-each');

var array = [1, 2, 3, 4, 5];

array.setEach((a) => { a += 3; });

console.log(array);

output

[ 4, 5, 6, 7, 8 ]

why?

Array.prototype.forEach does not change any values:

var array = [1, 2, 3, 4, 5];

array.forEach((a) => { a += 3; });

console.log(array);

output

[ 1, 2, 3, 4, 5 ]