Term: destructuring assignment (deconstruct assignment)
This is a new term introduced by JavaScript 1.7. As for the purpose, people who have used programming scripts such as MATLAB and Lua are no longer familiar with it.
VaR A = 1;
VaR B = 3;
[A, B] = [B, a];
In other words, multiple copies are written in one row. The main purpose is to return multiple return values, because such scripts neither have pointers nor reference parameters. Of course, it can also be used to exchange the value of a variable (as shown in the preceding example) and rotate the value of a variable sequence cyclically.
Javascript gave it such a strange name, probably because it uses its original array form. Assign an array to another array, which is a reference value. However, if the left side is a right value constant, the value cannot be assigned. Therefore, the semantics is changed to assign the value of each element to the corresponding element on the left. Therefore, it is called deconstruct value assignment, that is, the structure of the array.
Even more, destructuring looks familiar, like the destructor of C ++. Since destructor is translated into an analysis structure, why should destructure be translated into deconstruct? Check the professional dictionary and you will find that destruct and destructure are different. Destruct is destructive, crushing, and destructure is deconstruct. Obviously, destructor is the acronyms of destruct. The question is why destructor translates it into a destructor, rather than destroying or destroying a function. There is a separate and scattered interpretation of the word analysis, that is, the analysis of the split. There is also some truth in this thinking, and sharing a word structure with the constructor makes it easy to link the constructor with the constructor.