Khoa Nguyen
Pressure creates diamonds
Skip to main content

JavaScript Advanced Concept - Nullish Coalescing

Last updated: 10 May 2024 (8 month ago)

Nullish Coalescing

Nullish coalescing is a relativly new operator that was introduced in ES2020. It is similar to the logical OR operator ||, but it only returns the right-hand side if the left-hand side is null or undefined.

const foo = null ?? 'bar';
console.log(foo); // 'bar'

const foo = 0 ?? 'bar';
console.log(foo); // 0
  • E-commerce
  • Landing page
  • Usability
  • Accessibility
  • Information Architecture
  • Responsive Design