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?
Asked
Active
Viewed 25 times
0
-
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator – Danial Aug 28 '21 at 07:11
1 Answers
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
-
thank you so much MrMikimn for your valuable comment. I got the thing. – Md Sakib Al Islam Aug 28 '21 at 07:18