简体   繁体   English

对象解构:如何使用中间嵌套属性

[英]object destructuring: how to use intermediate nested property

var { iWantThis: { andThis, andThisToo } } = x;

Is there a way to get access to all three in one destructuring call? 有没有办法在一次解构调用中访问所有三种? I want to avoid two calls like so: 我想避免两次这样的调用:

var { iWantThis } = x;
var { andThis, andThisToo } = iWantThis;

The closest I can come up with is: 我能想到的最接近的是:

var { iWantThis, iWantThis: { andThis, andThisToo } } = x;

Thought I'd use let instead, if I'm using ES6 ;) 我以为我会使用let ,如果我使用的是ES6;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM