JavaScript & TypeScript

Optional Chaining

/ˈɒpʃənəl ˈtʃeɪnɪŋ/

Definition

The ?. operator that short-circuits and returns undefined instead of throwing when accessing a property of null/undefined.

Example in context

"user?.address?.city returns undefined safely if user or address is null — no TypeError crash."

Related terms

Practice this term

Master Optional Chaining in context by working through exercises in the JavaScript & TypeScript module. You'll see the term used in real engineering scenarios with multiple-choice, fill-in-the-blank, and matching drills.