Is it possible to use the destructuring assignment in the constructor of a JavaScript class to assign instance variables similar to how you can do this with regular variables?
The following example works:
var options = {one: 1, two: 2}; var {one, two} = options; console.log(one)
But I can't get something like the following to work:
class Foo { constructor(options) { {this.one, this.two} = options;
javascript variable-assignment destructuring
Aaron
source share