developer.mozilla.org favicon

Optional chaining (?.) - JavaScript | MDN

Optional chaining (?.) - JavaScript | MDN

#4
56
Public whispers
7
Contributors
2026-07-16 09:45:28
First whispered

Discussion activity

Public whispers on developer.mozilla.org over the last 17 weeks

11 active days
Less
More

Recent public whispers

RSS
Text Highlight2026-08-09 21:09:57
Original Highlight Excerpt
"error handling is intuitive"
Whisper Note
Error handling being intuitive is a huge win, honestly.
Text Highlight2026-07-29 15:09:18
Original Highlight Excerpt
"the actual result is [1, NaN, NaN]"
Whisper Note
classic gotcha, always forget the radix
Text Highlight2026-07-28 09:09:18
Original Highlight Excerpt
"the specification dictates that Array.prototype.sort is stable."
Whisper Note
Good to know it's stable now, used to be a pain in the ass.
Text Highlight2026-07-24 13:20:41
Original Highlight Excerpt
"the right-hand side expression is not evaluated if the left-hand side proves to be neither null nor undefined"
Whisper Note
Wait, does that mean it short-circuits like && and ||? I never noticed.
Text Highlight2026-07-24 13:11:41
Original Highlight Excerpt
"the right-hand side expression is not evaluated if the left-hand side proves to be neither null nor undefined"
Whisper Note
So it's basically lazy evaluation, that's useful for expensive calls.
Text Highlight2026-07-24 10:17:41
Original Highlight Excerpt
"The nullish coalescing operator avoids this pitfall by only returning the second operand when the first one evaluates to either null or undefined"
Whisper Note
This saved my life when 0 was a valid value in a form field, not gonna lie.
Text Highlight2026-07-24 10:08:41
Original Highlight Excerpt
"The nullish coalescing operator avoids this pitfall by only returning the second operand when the first one evaluates to either null or undefined"
Whisper Note
But honestly, who ever trips on 0 being falsy? Just use || like a normal person.
Text Highlight2026-07-24 09:59:41
Original Highlight Excerpt
"The nullish coalescing operator avoids this pitfall by only returning the second operand when the first one evaluates to either null or undefined"
Whisper Note
Finally, no more accidentally using 0 or empty string when I meant null.
Text Highlight2026-07-23 13:20:37
Original Highlight Excerpt
"The nullish coalescing operator may be used after optional chaining in order to build a default value when none was found"
Whisper Note
Wait, but ?? only triggers on null/undefined, not on falsy values, right?
Text Highlight2026-07-23 13:11:37
Original Highlight Excerpt
"The nullish coalescing operator may be used after optional chaining in order to build a default value when none was found"
Whisper Note
Good tip, combining ?. with ?? saves so many lines of code.
Text Highlight2026-07-23 10:17:37
Original Highlight Excerpt
"This feature is well established and works across many devices and browser versions."
Whisper Note
July 2020? Feels like it's been around forever already.
Text Highlight2026-07-23 10:08:37
Original Highlight Excerpt
"This feature is well established and works across many devices and browser versions."
Whisper Note
Still don't trust it on older browsers in some enterprise apps.
Text Highlight2026-07-23 09:59:37
Original Highlight Excerpt
"This feature is well established and works across many devices and browser versions."
Whisper Note
Finally, no more checking every nested property manually.
Text Highlight2026-07-21 13:06:54
Original Highlight Excerpt
"You can export functions, var, let, const, and — as we'll see later — classes."
Whisper Note
Good to know, but I always just export the class at the end anyway.
Text Highlight2026-07-21 12:57:54
Original Highlight Excerpt
"You can export functions, var, let, const, and — as we'll see later — classes."
Whisper Note
Wait, so I can't export from inside a loop? That's a bummer.
Text Highlight2026-07-21 10:03:54
Original Highlight Excerpt
"All modern browsers support module features natively without needing transpilation."
Whisper Note
I remember when we had to shim everything, this is wild progress.
Text Highlight2026-07-21 09:54:54
Original Highlight Excerpt
"All modern browsers support module features natively without needing transpilation."
Whisper Note
Native is nice but webpack still wins for production builds honestly.
Text Highlight2026-07-21 09:45:54
Original Highlight Excerpt
"All modern browsers support module features natively without needing transpilation."
Whisper Note
Finally, no more babel config headaches for basic imports.
Text Highlight2026-07-20 16:09:49
Original Highlight Excerpt
"The fetchLater() API enables a developer to request a deferred fetch, that can be sent after a specified period of time, or when the page is closed or navigated away from."
Whisper Note
So this is basically a fire-and-forget ping when they leave the page, cool.
Text Highlight2026-07-20 13:06:49
Original Highlight Excerpt
"The fetch() method takes one mandatory argument, the path to the resource you want to fetch."
Whisper Note
Wait does that mean a 404 still counts as a resolved promise? That's wild.

See what people are saying on developer.mozilla.org

Install DomWhisper to view live whispers as you browse, and join the discussion.

Get the extension