On 08/29/2018 12:13 PM, Bob Myers wrote:
In the stupid idea of the day department, for some reason I have felt
the urge more than once in recent months for an operator which would
invert the value of a boolean variable while evaluating to its
pre-inversion value. For example:
```js
if (bool!!) console.log("used to be true");
```
The post-inversion case is less important since I can just write `if
(bool = !bool)`.
There's always
if (counter++ & 1) console.log("used to be true");
if (++counter & 1) console.log("is now true");
or (counter++ % 2) if you prefer. And you get a free cycle counter in
the bargain! (At the cost of flatlining to false at 2**53.)
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss