The closest I can come up with is:
var { iWantThis, iWantThis: { andThis, andThisToo } } = x;
Though I’d use let
instead, if I’m using ES6 😉
More Related Contents:
- One-liner to take some properties from object in ES 6
- What is destructuring assignment and its uses?
- Where can I get info on the object parameter syntax for JavaScript functions?
- Is it possible to destructure onto an existing object? (Javascript ES6)
- What does curly brackets in the `var { … } = …` statements do?
- ES6/ES2015 object destructuring and changing target variable
- How do I destructure all properties into the current scope/closure in ES2015?
- ES6 destructuring function parameter – naming root object
- How to destructure object properties with key names that are invalid variable names?
- Destructuring in Node.JS
- Destructuring and rename property
- ES6 Destructuring and Module imports
- Destructuring Nested objects in javascript | Destructure second level parent and child Objects
- ES6 destructuring object assignment function parameter default value
- How to destructure option argument with all default values in ES6?
- Curly brackets (braces) in Node.js ‘require’ statement
- Node JS / V8 destructuring bug?
- How to bind methods when destructuring an object in JavaScript?
- Backticks (`…`) calling a function in JavaScript
- ES6 modules: Export single class of static methods OR multiple individual methods
- Anonymous class instance —- is it a bad idea?
- Javascript ES6 class definition not accessible in window global
- How to use code from script with type=module [duplicate]
- How to clone a javascript ES6 class instance
- Spreading undefined in array vs object
- React.createClass vs. ES6 arrow function
- ES6 – Call static method within a class
- Are ES6 template literals faster than string concatenation?
- Javascript: Using `.includes` to find if an array of objects contains a specific object
- ES6 module scope