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
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.
Javascript Shorthands Tips
These Javascript shorthand tips will make your code look more cool and clean.
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
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.