On 04 Dec 2013, at 9:13 , Olov Lassus <[email protected]> wrote:
> I wanted to do
>
> if (const val = compute(something)) {
> // ...
> }
>
> but I had to do
>
> let val;
> if (val = compute(something)) {
> // ...
> }
>
> which is unfortunate not only because val leaks to the outer scope but also
> because let suggest that the binding mutates (which it technically does, but
> practically doesn't).
I’m curious, why not:
```js
const val = compute(something);
if (val) {
// ...
}
```
One thing that makes me skeptical w.r.t. `if`: will this kind of in-statement
declaration only be used for truthy/falsy tests? In loops (for-of, while), I
find this kind of thing useful, for if-then-else, much less so.
--
Dr. Axel Rauschmayer
[email protected]
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss