Editor loading ... Mode 1,length assignment to 0 This is a very interesting way,
Other languages, such as Java, have an array whose length is read-only and cannot be assigned a value. such as int[] ary = {1,2,3,4}; ary.length = 0; Java will error, compile pass.
And JS can be, and the array is emptied, var ary = [1,2,3,4]; ary.length = 0; Console.log (ary); Output [], empty array, which is emptied of the current prototype array in the clear and MooTools libraries in the array of empty use this way to empty the array.
Mode 2, the assignment is [] var ary = [1,2,3,4]; ary = []; Assignment to an empty array to clear the original array here is actually not the strict meaning of emptying the array, just ary the value to an empty array, before the array if there is no reference in point to it will wait for garbage collection.
Two ways to empty the JS array