Re: Conditional assign operator

2020-04-14 Thread Naveen Chawla
Yes I like syntactic sugar when it doesn't sacrifice clarity (e.g. class, arrow functions). However, I do like the logical assignment operator pointed out by Jordan somewhat more than the "conditional assign" ("if not assigned") idea at the beginning of this thread. My reason is that you cannot

Re: Conditional assign operator

2020-04-13 Thread Bergi
Hi! > What I've long wanted is an assignment operator which evaluates to the > pre-assignment value of the LHS. > You know, sort of like `a++` evaluates to the pre-incremented value of `a`. Given the amount of confusion that the difference between `++a`, `a++` (and `a += 1`) already has caused,

Re: Conditional assign operator

2020-04-13 Thread Bob Myers
What I've long wanted is an assignment operator which evaluates to the pre-assignment value of the LHS. You know, sort of like `a++` evaluates to the pre-incremented value of `a`. We could call this this "post-assignment" operator. Has anyone ever proposed that? ``` let a = 1; console.log(a =^=

Re: Conditional assign operator

2020-04-13 Thread Jordan Harband
Are you familiar with https://github.com/tc39/proposal-logical-assignment/ ? On Mon, Apr 13, 2020 at 2:17 AM Sultan wrote: > The following would assign to the address foo in obj if and only if it has > not already been assigned. > > var obj = {} > var foo = Math.random() > obj[foo] ?= 1 > > The

Re: Conditional assign operator

2020-04-13 Thread 森建
See Stage 3 Logical Assignment Proposal. https://github.com/tc39/proposal-logical-assignment Thanks. 2020年4月13日 18:17 +0900、Sultan のメール: > The following would assign to the address foo in obj if and only if it has > not already been assigned. > > var obj = {} > var foo = Math.random() >