var array1 = [1, 2, 3, 4, 5];
// function 1 below which assigns a whole new value to an array, doesn't work
function changeArray(array) {
array = ["A", "B", "C"];
};
// function 2, which simply modifies one element within an array, does work
function addArray(array) {
array.push(6);
}
**// If I run function one (changeArray) on array1 and then try to print array1, it remains unchanged. However, running function 2 (addArray) does indeed add another element "6" into the array. What am I missing?
changeArray()work. (To fend of the "but pass an object!" objections, such a solution would result in a function that's not like this one.)arrayvariable (the parameter), not the global one.