A Nullish Coalescing (in JS) Tutorial for Normal People
Too Long; Didn’t Read
The nullish coalescing operator (??) is a short, simple way to provide a default value when something is null or undefined. Instead of having messy nested ternaries or logical OR statements, you can use the double question mark operator to coalesce to a default. The?? operator will return the left side if it’s not nullish (meaning null orefined), otherwise it will return right side.
Too Long; Didn’t Read
The nullish coalescing operator (??) is a short, simple way to provide a default value when something is null or undefined. Instead of having messy nested ternaries or logical OR statements, you can use the double question mark operator to coalesce to a default. The?? operator will return the left side if it’s not nullish (meaning null orefined), otherwise it will return right side.