Is it possible to destructure instance/member variables in a JavaScript constructor?
There are multiple ways of doing this. The first one uses destructuring only and assigns the properties of options to properties on this: class Foo { constructor(options) { ({one: this.one, two: this.two} = options); // Do something else with the other options here } } The extra parentheses are needed, otherwise the JS engine might … Read more