developer.mozilla.org favicon

Optional chaining (?.) - JavaScript | MDN

Optional chaining (?.) - JavaScript | MDN

#4
56
公开标注数
7
参与人数
2026-07-16 09:45:28
首次 Whisper

讨论活跃度

developer.mozilla.org 近 17 周的公开 Whisper

11 活跃天数

最新公开 Whisper

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

看看大家在 developer.mozilla.org 上划了什么重点

安装 DomWhisper,浏览网页时实时查看 whisper,也可以加入讨论。

获取插件