ES6多层解构


const info = {
  person: {
    name: 'xiaobe',
    other: {
      age: 22,
    }
  },
  song: 'rolling',
}

// 解构person的内容
const { person: { name, other: { age } } } = info;

// 解构song
const { song } = info;

但请注意, personother是属于未定义的变量

参考ES6非常棒的特性-解构


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM