I don't know exactly how to title this but here is an exemple
I pass an array to a function, and I want that all the changed inside the function are applied to the array that was passed by ref (event the []) =>
var myArray = [1,2,3,4];
function resetter(arr){
arr = []
}
resetter(myArray); // still [1,2,3,4] because I assign a new object
but I want that changed to be applied to my array I passed as a reference
var myArray = [1,2,3,4];
function resetter(arr){
arr.length = 0;
}
resetter(myArray); // [] but is this clean ?
are there any other way ?