What does the optional chaining operator `?.` do?

JavaScript Associate Medium

JavaScript Associate — Medium

What does the optional chaining operator `?.` do?

Key points

  • The optional chaining operator helps avoid errors when accessing nested properties.
  • It simplifies code by handling null or undefined references gracefully.
  • This operator is particularly useful when dealing with APIs that may return incomplete data.

Ready to go further?

Related questions