0

Recently I am working on an official project, where I see ?? operator, but I can not understand what is this thing and how it works. Can anyone describe me?

  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator – Danial Aug 28 '21 at 07:11

1 Answers1

0

It's the nullish coalescing operator. It returns the left-hand side of the operator if it is not nullish, and the right-hand side otherwise

Example:

let a = undefined ?? 1 // returns 1
let b = 2 ?? 3 // returns 2
let c = 0 ?? 3 // returns 3
MrMikimn
  • 721
  • 1
  • 5
  • 19