I want to make a function that completely override the original array.
function putDatainthis(arr) {
//....some ways to get data
arr = [data,data,data...]; //this just reassigns arr = to new array original that was passed as reference hasn't been modified.
}
//so right now only way i can think of is this:
function putDatainthis(arr) {
var data = [3,4,6,2,6,1];
arr.length=0;
data.forEach(function(e){
arr.push(e);
});
}
but i want to know can it be improved or is there more native way.