While using property references in destructuring patterns can be expressive, it can suffer from a few problems:
({ a: this.b } = obj);
and
({ a = this.b } = obj);
Tracing the however intended side effects may be confusing as one might be inclined to gloss over full property references on the left hand side where they don't normally occur and where normally only some straightforward local declarations occur.
Property references on the left-hand side may allow extended complex and difficult to read expressions which are even more cluttered when mixed in to destructuring:
var a = true, b = {d: 4}, c = {d: 88};
({x: (a ? b : c).d} = {x: 5}); // b.d === 5
b = false;
({x: (a ? b : c).d} = {x: 5}); // c.d === 5
While local variables are also defined within the left-hand-side, these are only local in scope and easier to visually track).
var obj = {};
({ a: this.b } = obj);
var obj = {};
({ a: (true).b } = obj);
var arr = [];
([ this.a ] = arr);
var obj = {a: null};
var x = true;
var y = {b: 1};
var z = {b: 2};
({ a: (x ? y : z).b } = obj);
var c;
var obj = {a: 5};
({ a: c } = obj);
var obj = {a: {b: 15}};
({ a: {b: {c} }} = obj);
var a;
var arr = [3];
[ a ] = arr;
var obj = {};
var a;
({ a } = obj);
this.b = a;
var obj = {a: null};
var x = true;
var y = {b: 1};
var z = {b: 2};
({ a: (x ? y : z).b } = obj);
var arr = [];
var a;
([ a ] = arr);
this.a = a;
var obj = {a: null};
var x = true;
var y = {b: 1};
var z = {b: 2};
({ a } = obj);
(x ? y : z).b = a;
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too