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.

Frequently Asked Questions

What does "Optional Chaining" mean?

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

How do you pronounce "Optional Chaining"?

"Optional Chaining" is pronounced /ˈɒpʃənəl ˈtʃeɪnɪŋ/.

Can you use "Optional Chaining" in a sentence?

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