<分区>
我正在使用 ArrayList 作为我的数组,
let ArrayList = ['a','b','c','d','e','f'];
我对方法 1 和方法 2 感到困惑,因为在这两种情况下我都引用了另一个 ArrayList,您也可以通过此链接查看日志 https://jsfiddle.net/mnjsnj/u1fms8wx/2/
方法一
let Method1 = ArrayList; // Referenced arrayList by another variable
ArrayList= []; // Empty the array
console.log(Method1); // Output ['a','b','c','d','e','f']
方法二
let Method2 = ArrayList; // Referenced arrayList by another variable
ArrayList.length = 0; // Empty the array by setting length to 0
console.log(Method2 ); // Output []