I want to pass an object or array to a function, make it undefined, and see the changes after the function execution ends.
var arr = [\'aaa\', \'bbb\', \'ccc\'];
You can't pass a variable by reference in JavaScript. What you can do instead, if the variable is in the same or greater scope than reset(), is use the variable itself inside the function as shown below:
var
arr = ['aaa', 'bbb', 'ccc'],
reset = function () {
arr = undefined;
}
reset();
console.log(arr);
Or instead you can just make it equal to undefined:
var arr = ['aaa', 'bbb', 'ccc'];
arr = undefined;
console.log(arr);