Optional Chaining Operator
(formerly Null Propagation Operator)
Spec Author: Claude Pache
Champion: Gabriel Isenberg
Goals
Recap: Syntax
obj?.prop // optional property access�obj?.[expr] // optional property access�func?.(...args) // optional function or method call
Syntax:
Semantics:
a?.b // undefined if a is null/undefined, a.b otherwise�a?.[++x] // If a evaluates to null/undefined, the variable x is *not* incremented.�a?.b.c().d // undefined if a is null/undefined� // throws if b or c is null/undefined� // throws if c() returns null/undefined��a?.() // a is invoked if not null/undefined
Recap: Questions from stage 1 meeting
Should we return undefined, null, or null and undefined?
�More discussion: Write justification for choices in syntax and semantics
How should computed property access be handled?
Short circuiting and free grouping
Is there only syntax for property lookup?
Open questions and issues
Status
Q&A