On Tue, Mar 20, 2018 at 3:57 PM, Rodrigo <[email protected]> wrote:
> Proposal: inline let/const statements to declare and initialize
> variables within if statements, so that temporary variables exist only
> within the if/else block scope.
>
With setters you can get some oddities because the getter need not return
the same value set.
const o = { get x() { return this.x_ }, set x(v) { return this.x_ =
String(v) } }
if (!(o.x = 0)) {
console.log('o.x is falsey: ' + !o.x);
}
If decorators <https://github.com/tc39/proposal-decorators/issues/51> are
allowed on let/const declarations, then you might get a similar source of
confusion.
This might be especially confusing since in Java and C++ the result of an
assignment is
the value actually assigned after any type coercion (or a reference to the
left).
In JavaScript, the result of an assignment is the result of the right
operand.
Though its a bit muddy, since the result of x++ is x coerced to a number
for symmetry with x += 1.
If it turns out that decorators are widely used for type annotations on
declarations and
some do custom coercion on assignment, does that introduce potential
problems?
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss