In your case, a variable itemis passed by value because it has a primitive value. If it were a json object, and you would change one of its properties, this would be reflected in the original list.
In this situation, you can use other arguments that it has forEach. For instance:
arr.forEach(element, index, array) {
...
}
Using these arguments, you can directly influence array[index]
source
share