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 does the optional chaining operator ?. do?

  1. A Throws an error if the value is null
  2. B Returns undefined instead of throwing when accessing a property of null or undefined
  3. C Provides a default value
  4. D Makes a property optional in a class
Answer

Returns undefined instead of throwing when accessing a property of null or undefined

obj?.a?.b short-circuits to undefined if any link is null or undefined, avoiding a TypeError. The ?? operator supplies a default value.

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