Question · JavaScript and TypeScript course · Module 7: Advanced TypeScript

Optional chaining and nullish coalescing

What does dino?.enclosure?.location ?? null return when dino is undefined?

Answer options

  • null - optional chaining stops the read and ?? returns the default value
  • Error: Cannot read property of undefined
  • undefined
  • An empty object {}

You can check the correct answer by solving this task in the CodeWorlds game.