When working with arrays in JavaScript, how can I mutate the value of an array inside a function? I'm aware that certain array methods can achieve this, but regular assignment doesn't seem to work.
var arr = [4];
function changeArray(arr) {
arr = [1, 2, 3];
}
// The value of "arr" remains [4]. How can I make it [1, 2, 3]?
I believe that this code does not alter the value of "arr" outside of the function. Is there a way to mutate the array passed as an argument in order to achieve this?