AND and OR in if statement

Andy Earnshaw 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()
  &&(bar)

is equivalent to `a = foo() && bar`, but

a = foo()
  AND(bar)

is equivalent to

a = foo();
AND(bar);

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.
> JavaScript's syntax was, amongst others, heavily influenced by C-family
> 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
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160525/94c3b065/attachment.html>


More information about the es-discuss mailing list