AND and OR in if statement
andyearnshaw at gmail.com
Wed May 25 08:16:43 UTC 2016
It's not feasible anyway because AND and OR are already valid identifiers:
a = foo()
is equivalent to `a = foo() && bar`, but
a = foo()
is equivalent to
a = foo();
On Wed, 25 May 2016 at 02:29 kdex <kdex at kdex.de> wrote:
> Could you explain how your second example is cleaner? All I see is that
> it's longer; the rest is merely a matter of taste.
> languages (which went for `&&` and `||` as well as `&` and `|`).
> Next, I think it's confusing that, although we're calling it "bitwise and"
> and "bitwise or", we would only be able to write `and` or `or` in a logical
> context; this choice is entirely arbitrary. Bitwise operators would still
> need to be `&` and `|` since there's no way to tell what your intent is
> just from the syntax.
> IMHO, the current operators `&&`, `&`, `||` ,`|` are the cleanest
> implementation of `and` and `or` that I could think of.
> On Dienstag, 24. Mai 2016 21:14:59 CEST Francis Clavette wrote:
> > Hi,
> > I’d like to be able to use AND for && and OR for || in conditional
> statements in a future version of ECMAScript. It’s a feature I’ve always
> been wanting since transitioning from PHP. It’s also much cleaner :
> > if ($scope.newSourceModal.isShown() && $scope.newsource.type == "book"
> && (!$scope.insertingFromScan || $scope.ok))
> > ==============
> > if ($scope.newSourceModal.isShown() AND $scope.newsource.type == "book"
> AND (!$scope.insertingFromScan OR $scope.ok))
> > Francis
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss