Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #40988

Re: JSLint: "Wrap a ternary expression in parens, ..."

From ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups comp.lang.javascript
Subject Re: JSLint: "Wrap a ternary expression in parens, ..."
Date 2022-07-15 06:27 +0000
Organization Stefan Ram
Message-ID <conditional-20220715072630@ram.dialup.fu-berlin.de> (permalink)
References <tapv73$1pkf$1@gioia.aioe.org>

Show all headers | View raw


emf <emfril@gmail.com> writes:
>What is now the correct syntax for the ternary expression?

  IIRC, JSLint does not check syntax but its authors idea of style.

  The syntax for the conditional expression is

ConditionalExpression[In, Yield, Await] :
ShortCircuitExpression[?In, ?Yield, ?Await]
ShortCircuitExpression[?In, ?Yield, ?Await] ? AssignmentExpression[+In, ?Yield, ?Await] :
AssignmentExpression[?In, ?Yield, ?Await]

  , so, you can just write, for example, "0?1:1?2:3"
  (which would evaluate to 2).

Back to comp.lang.javascript | Previous | Next | Find similar | Unroll thread


csiph-web