1. shorthand
The first is the object key == value, it can be abbreviated as
let obj={
hello: hello // can be abbreviated to hello
}
Method object shorthand
es5中 let obj = { hello :function(){} } es6中 let obj={ hello(){} }
2. The expression properties
Obj The key may be a variable
let a = hello let obj={ [a]="123" }
3. traverse the object in the key and value
let test = { k:'12', l:'23' } for(let [key,value] of Object.entries(test)){ console.log([key,value]) }
4. Extended operator
A {the let, B, C} = {A ...: ' . 1 ' , B: ' . 3 ' , C: ' 22 is ' , H: ' 33 is ' } A = . 1 B = . 3 C = [ 22 is , 33 is ] ... that the rest are his
Classic 5.var and let the for loop
Var principle is no scope, he did not execute down, but after waiting cycle is over, so each print is maximum
let's let scoped variables can not be repeated declarations
const is a constant defined, blind not change, but if an object is defined, it can be modified, because it is the reference address
6. array of deconstruction assignment
let a,b,c
[a,b] = [1,2]
a=1 b=2
The default value of the array
[a,b,c=3]=[1,2]
c=3
Switching array
let a=0;b=1
[a,b] = [b,a]
I do not want to ignore certain laws, as long as I want my
[a,,,b] = [1,2,3,4]