This is a very basic problem, but we often do wrong. When an array needs to be cleared, many people use the following method: A = []; we know that the Javascript variable storage method is divided into reference type and direct quantity. The array belongs to the object, that is, the reference type. It references the variable pointer address, which is designed to save memory. In addition, the preceding empty array method is used. If a new array is assigned directly, the referenced array may not be released (with other references). For exampleCode: Var A = [2, 3]; var B = A; A = []; console. log (B); at this time, A and B are not the same array. Clearing a and B still refer to the previous reference address. Unless you intentionally do, this will pose a risk. Therefore, the best way to empty the array is to set the length to 0, that is, a. Length = 0; [reprint address: http://js8.in/1116.html]