Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

What is the difference between the nullish coalescing operator (??) and the logical OR operator?

  1. A ?? falls back only when the left side is null or undefined; logical OR falls back for any falsy value
  2. B They behave identically in every case
  3. C Logical OR works only with boolean operands
  4. D ?? works only with numeric operands
Answer

?? falls back only when the left side is null or undefined; logical OR falls back for any falsy value

This matters when 0 or an empty string are legitimate values. count ?? 10 keeps a real 0, whereas the OR form would replace it with 10.

All Javascript MCQs

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as