<script> //数组的解构赋值 按照索引顺序解构赋值 const listArray = ['zhangsan','lisi','wangwu','zhaoliu']; let [san,si,wu,liu] = listArray; console.log(san,si,wu,liu); //res => zhangsan lisi wangwu zhaoliu //对象的解构赋值 按照键值对的方式进行解构赋值 const listObj = { name:'zhangsan', age:18, fanwaikuangtu(){ console.log('jiushiwo'); } } let {name,age,fanwaikuangtu} = listObj; console.log(name,age,fanwaikuangtu); /* res => zhangsan 18 ƒ fanwaikuangtu(){ console.log('jiushiwo'); } */ </script>
标签:ES6,console,log,fanwaikuangtu,解构,zhangsan,赋值 From: https://www.cnblogs.com/Dalian99/p/17936402.html