标签:fir abc undefined 数据 one name 变量 trie log
//数组解构 let arr = [1,2,3,4,5,6,7] let [one,two] = arr let [one, , ,four] = arr console.log(one,two,four) let arr = ‘abcd‘ let [first, ,third] = arr console.log(first,third) let [first, ,third] = new Set([1,2,5,6,7]) console.log(first,third) let user = { name:‘s‘,surname:‘t‘}; [user.name,user.surname] = [1,2] console.log(user) //循环解构 let user = { name:‘s‘,surname:‘t‘}; for( let [k,v] of Object.entries(user)){ console.log(k ,v) } //剩余变量解构 let arr = [1,2,3,4,5,6,7,8,9] let [first,second,...last] = arr console.log(first,second,last) //当数据为空时,解构赋值为undefined let arr = [] let [first,second,...last] = arr //可以设置默认值 let [first=‘a‘,second,...last] = arr console.log(first,second,last)
标签:fir abc undefined 数据 one name 变量 trie log
原文地址:https://www.cnblogs.com/qjb2404/p/12210652.html