"01"deconstruction assignment of arrays
Konjac Summary:Usage 1:var [a,b,c]=[1,2,3];
Usage 2: (can be nested arrays)let [foo, [[Bar], Baz]] = [1, [[2], 3]];
foo//1bar//2baz//3
Usage 3: (can variable name is empty, the number of variable value is more than the number of variables)Let [,, third] = ["foo", "Bar", "Baz"];
Third//"Baz"
Usage 4: (add 3 points before the variable, expressed as an array, note the value of the variable)Let [head, ... tail] = [1, 2, 3, 4];head//1tail//[2, 3, 4]
Usage 5: (when the number of variable values is less than the number of variables, the variable is undefined)Let [x, Y, ... z] = [' A '];x//' a ' Y//Undefinedz//[]
Knowledge 6: The variable is undefined when deconstructedKnowledge 7: When partially deconstructed,deconstruction can still succeed. Knowledge 8:if the right side of the equal sign is not an array (or, strictly speaking, not a ergodic structure), an error will be reported.
Knowledge 9: Deconstruction assignment applies not only to the Var command, but also to the Let and const commands.
Knowledge:The deconstruction assignment allows you to specify a default value. The default value can only be used if the variable is equal to (= = =) undefined.
Deconstruction assignment of "01" Array