Skip to content

Logical expression syntactic sugar  #776

@jw013

Description

@jw013

Section 1.1.6 says (paraphrasing) that e1 && e2 is syntactic sugar for e1 ? e2 : false, and e1 || e2 is syntactic sugar for e1 ? true : e2. Strictly speaking, in JavaScript, e1 && e2 is syntactic sugar for e1 ? e2 : e1 and e1 || e2 is syntactic sugar for e1 ? e1 : e2.

Direct link to the relevant portion of the language specification: https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#sec-binary-logical-operators-runtime-semantics-evaluation

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions