Using the Nullish Coalescing Operator (??) in Javascript


Use ?? to provide a default value if the first value is null or undefined.

Source Code

let userName = null;
let displayName = userName ?? 'Guest';
console.log(displayName);
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments