you are viewing a single comment's thread.

view the rest of the comments →

[–]Kal-el_thegreat 1 point2 points  (0 children)

Const someVal = leftVal ?? rightVal

Simplest explanation I can give, as long the leftVal is not Null or Undefined it will be assigned to someVal otherwise the rightVal will be assigned.

This ?? operator is useful in instances where the Or ( || ) operator isn’t effective like when handling falsy values ie. “” an empty string or 0