Repository navigation
Description
Describe the Issue
The lesson "What Are Binary Logical Operators, and How Do They Work?" incorrectly explains that the nullish coalescing operator (??) works with falsy values, when it actually only works with nullish values (null and undefined):
Here is an example of working with the nullish coalescing operator:
const result = null ?? 'default'; console.log(result); // defaultSince
nullis a falsy value, the stringdefaultwould be logged to the console.
However, the nullish coalescing operator (??) does not check for falsy values.
According to MDN: The nullish coalescing (
??) operator is a logical operator that returns its right-hand side operand when its left-hand side operand is null or undefined, and otherwise returns its left-hand side operand.
Affected Page
Your code
// Nullish coalescing (??) - only checks for null/undefined
console.log(0 ?? 'default'); // 0 (not 'default')
console.log('' ?? 'default'); // '' (not 'default')
console.log(false ?? 'default'); // false (not 'default')
console.log(null ?? 'default'); // 'default'
console.log(undefined ?? 'default'); // 'default'
// OR operator (||) - checks for ALL falsy values
console.log(0 || 'default'); // 'default'
console.log('' || 'default'); // 'default'
console.log(false || 'default'); // 'default'
console.log(null || 'default'); // 'default'
console.log(undefined || 'default'); // 'default'Expected behavior
Here is an example of working with the nullish coalescing operator:
const result = null ?? 'default'; console.log(result); // defaultSince
nullis a nullish value (eithernullorundefined), the nullish coalescing operator returns the right-hand operand, and the stringdefaultwould be logged to the console.
Screenshots
No response
System
n/a
Additional context
No response
Activity
garyeung commentedon Nov 1, 2025
I think the course is explained very clearly.
majestic-owl448 commentedon Nov 1, 2025
the only sentence that seem to be updating is
it should be "Since
nullis a nullish value, the stringdefaultwould be logged to the console."or there are other issues that I am not noticing? The explanation above the example seems fine
l3onhard commentedon Nov 1, 2025
Yes, I meant to say that only the sentence needs correction.
shashankdangi commentedon Nov 2, 2025
Can i work on it ? or is it still in discussion ?
majestic-owl448 commentedon Nov 2, 2025
@shashankdangi when an issue has the help wanted label it means it is open for contributors to work on