1.es6 three kinds declaratively:
a.var global declarations
b.let local variable declaration
c.const constant declaration
2. Variable assignment of deconstruction
a. array-valued deconstruction
The left and right of the equal sign in the form of uniform let [a, [b, c ], d] = [1, [2,3], 4];
You can use the default values let [a, b = "paradise "] = [ ' chase'] console.log (ab);
ps: undefined value indicates there is no value is null null
b. destructuring assignment object
1 let {head,foot} = {head:'paradise',foot:'追逐者'};
2 console.log(head foot);
Variables must be the same variable name
c. If you have previously defined variables, use parentheses
1 let foot;
2 ({foo} ={foot:'追逐者'});
3 console.log(foot);
d. strings deconstruction (and similar arrays)
1 const [a,b,c,d,e,f,g,h]="Paradise";
2 console.log(a);
3 console.log(b);
4 console.log(c);
5 console.log(d);
6 console.log(e);
7 console.log(f);
8 console.log(g);
9 console.log(h);
3. Extended operator and the rest operators
Programming parameters and solve an array of objects unknown circumstances
a. Object extended operator (...)
function paradise(...aaa){
console.log(aaa[0]);
console.log(aaa[1]);
console.log(aaa[2]);
console.log(aaa[3]);
}
paradise(1,2,3,4);
This incoming n input without error
let arr1=['aaa','bbb','ccc'];
//let arr2=arr1;
let arr2=[...arr1];
console.log(arr2);
arr2.push('ddd');
console.log(arr2);
console.log(arr1);
Resolve the reference (direct quote, change arr2 the same time, arr1 will change)
b.rest operator (...)
1 function paradise(first,...arg){
2 for(let val of arg){
3 console.log(val);
4 }
5 }
6
7 paradise(0,1,2,3,4,5,6,7); //输出7
More professional front-end knowledge, make the [2048] ape www.mk2048.com