DEV Community

loading...

Discussion on: Short-Circuit Evaluation in JavaScript

Collapse
talha131 profile image
Talha Mansoor • Edited

For your last point, JS now has Nullish Coalescing operator which has been added to fix this exact issue.

console.log(user.numberOfChildren ?? 'Unknown'); // 0
console.log(user.numberOfChildren || 'Unknown'); // Unknown