數(shù)組
普通:
let [ZS, LS, WW] = [30, 35, 40]
// ZS = 30
// LS = 35
// WW = 40
剩余:
let [ZS, ...LS] = [30, 35, 40]
// ZS = 30
// LS = [35,40]
字符串:
let arr = [ZS,LS,WW,TS] = "hell"
// ZS = "h"
// LS = "E" ...
對象
普通:
let obj = { detail: '123', detail22: '345' }
let { detail, detail22 } = obj
// detail = '123'
// detail22 = '345'
// ...
剩余:
let obj = { detail: '123', detail22: '345', detail33: '888' }
let { detail, ...all } = obj
// detail = '123'
// all = {detail22: '345' ,detail33:'888' }
// ...
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者