?? in JavaScript: the nullish coalescing operator.

Samuel Kendrick - May 2 '23 - - Dev Community
0 ?? "default";
// 0

false ?? "default";
// false

[] ?? "default"
// []

/** ⚠️ Pay attention.  */

null ?? "default";
// "default"

undefined ?? "default";
// "default"
Enter fullscreen mode Exit fullscreen mode

The ?? operator can be translated as: "return the value on the left UNLESS it's null or undefined. If the value is null or undefined, then use the value on the left of the ??.

<Avatar img={profilePicUrl ?? placeholder}/>
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . .
Terabox Video Player