Question · JavaScript and TypeScript course · Module 2: Functions, Arrays and Objects
Error Basics - Optional Chaining (?.)
What will the expression dinoRecord.medical?.lastCheckup?.date return if the dinoRecord object doesn't have a medical property?
Answer options
- It will return null
- It will throw a TypeError because medical doesn't exist
- It will return undefined without throwing an error
- It will return an empty string ""
Show the answer
Correct answer:
- It will return undefined without throwing an error