Bird
0
0

Which of the following is the correct syntax to safely access the author.name property in an Angular template when author might be null?

easy📝 Syntax Q3 of 15
Angular - Templates and Data Binding
Which of the following is the correct syntax to safely access the author.name property in an Angular template when author might be null?
A{{ author.name }}
B{{ author?.name }}
C{{ author?.name? }}
D{{ author.name? }}
Step-by-Step Solution
Solution:
  1. Step 1: Understand nested property access with safe navigation

    Use ?. before the property that might be null to avoid errors.
  2. Step 2: Evaluate options

    {{ author?.name }} correctly uses author?.name. Others misuse the operator or omit it.
  3. Final Answer:

    {{ author?.name }} -> Option B
  4. Quick Check:

    Safe navigation for nested property = author?.name [OK]
Quick Trick: Place ?. before property that might be null [OK]
Common Mistakes:
  • Placing ? after property
  • Using multiple ? incorrectly
  • Not using safe navigation when needed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes