the destructor assignment of a variable: ES6 allows you to extract values from arrays and objects in a certain pattern, assigning values to variables, which is called deconstruction (destructuring).
The previous wording:
var a = 1;var B = 2;
ES6 allowable wording:
Let [A, b] = [+];
General Purpose:
1. Value of exchange variable
[x, Y] = [y,x];
2. function returns multiple values
Function F1 () {return [+];} var [a,b,c] = F1 ();//Return JSON object: function F1 () {return {id:1,name: "Xiaoming"};} var {id,name} = f1 ();
3, the function of the order-free definition
Function F1 ({a,b,c}) {//...} F1 ({a=1,c=3,b=2});
4. Default values for parameters
Function F1 (a=1,b=2) {//...}
5. Traverse Map Deconstruction
var map = new map (), Map.set ("First": "Hello"), Map.set ("second": "World"),//Get key and Valuefor (let [key,value] of map) {//...} Get only keyfor (let [key] of map) {//...}
ES6 Sharing--the deconstruction assignment of variables