tc39 / proposal-optional-chaining-assignment

`a?.b = c` proposal
https://tc39.es/proposal-optional-chaining-assignment/
MIT License
188 stars 2 forks source link

What value does the assignment evalute to? #9

Open bakkot opened 5 months ago

bakkot commented 5 months ago

(From plenary, just capturing here since I don't see it anywhere.)

Consider:

let x = a?.b = c;

What value does x get?

(One possible solution is to say that this operator is only legal in statement position, though that's a little awkward to specify.)

zaygraveyard commented 5 months ago

My intuition matches the proposed de-sugaring in the README:

let x = (a == null ? undefined : a.b = c);