Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: ram@zedat.fu-berlin.de (Stefan Ram) Newsgroups: comp.lang.javascript Subject: Re: JSLint: "Wrap a ternary expression in parens, ..." Date: 15 Jul 2022 06:27:13 GMT Organization: Stefan Ram Lines: 16 Expires: 1 Apr 2023 11:59:58 GMT Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de yurT+Unr5fgF8XLM6FY9tg7OVdKJPGOLyywiox9AuUMXuB X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved. Distribution through any means other than regular usenet channels is forbidden. It is forbidden to publish this article in the Web, to change URIs of this article into links, and to transfer the body without this notice, but quotations of parts in other Usenet posts are allowed. X-No-Archive: Yes Archive: no X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some services to mirror the article in the web. But the article may be kept on a Usenet archive server with only NNTP access. X-No-Html: yes Content-Language: en-US Accept-Language: de-DE, en-US, it, fr-FR Xref: csiph.com comp.lang.javascript:40988 emf 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).