- const info = {
- person: {
- name: 'xiaobe',
- other: {
- age: 22,
- }
- },
- song: 'rolling',
- }
- // 解构 person 的内容
- const { person: { name, other: { age } } } = info;
- // 解构 song
- const { song } = info;
但请注意, person 和 other 是属于未定义的变量
参考 ES6 非常棒的特性 - 解构 https://zhuanlan.zhihu.com/p/34691255
来源: http://www.bubuko.com/infodetail-2994190.html