LogoDuyệtSr. Data Engineer
HomeAboutPhotosInsightsCV

Footer

Logo

Resources

  • Rust Tiếng Việt
  • /archives
  • /series
  • /tags
  • Status

me@duyet.net

  • About
  • LinkedIn
  • Resume
  • Projects

© 2026 duyet.net | Sr. Data Engineer | 2026-02-27

TL;DR - ES2020: Nullish Coalescing

Note: This post is over 6 years old. The information may be outdated.

The nullish coalescing proposal (??) adds a new short-circuiting operator meant to handle default values.

The nullish coalescing operator (??) acts very similar to the || operator, except that we don’t use "truthy" when evaluating the operator. Instead we use the definition of "nullish", meaning "is the value strictly equal to null or undefined". So imagine the expression lhs ?? rhs: if lhs is not nullish, it evaluates to lhs. Otherwise, it evaluates to rhs.

false ?? true // => false
0 ?? 1 // => 0
'' ?? 'default' // => ''

null ?? [] // => []
undefined ?? [] // => []

References

  • https://github.com/tc39/proposal-nullish-coalescing/
  • https://v8.dev/features/nullish-coalescing
Jun 28, 2020·6 years ago
|Web|
Web
|Edit|

Related Posts

Migrate to Cloudflare Pages

Cloudflare just released the Pages, with the most generous free tier, it is all set to compete with Netlify on this front. I just to try it out in this blog.

May 1, 2021·5 years ago
Read more

Javascript Shorthands Tips

These Javascript shorthand tips will make your code look more cool and clean.

Oct 20, 2019·6 years ago
Read more

Checklist tối ưu hiệu năng React

Muốn tối ưu hiệu năng React, sau đây là checklist để tăng tốc website sử dụng React

Mar 3, 2019·7 years ago
Read more

Web Performance 101

Trang web sau sẽ giới thiệu tất tần tật về tối ưu hiệu năng của modern web. Bài viết sẽ giải thích vì sao việc tối ưu là quan trọng, những công nghệ tối ưu và công cụ nào hiện đang được sử dụng, giải thích một cách chi tiết dễ hiểu và cách ứng dụng chúng.

Nov 13, 2018·7 years ago
Read more