Bird
0
0

Given this code snippet, what will be the length of the FormArray after execution?

medium📝 state output Q13 of 15
Angular - Reactive Forms
Given this code snippet, what will be the length of the FormArray after execution?
const tags = new FormArray([]);
tags.push(new FormControl('angular'));
tags.push(new FormControl('typescript'));
tags.removeAt(0);
A1
B2
C0
D3
Step-by-Step Solution
Solution:
  1. Step 1: Track push operations

    Two controls are added, so length becomes 2.
  2. Step 2: Apply removeAt(0)

    The first control is removed, reducing length by 1.
  3. Final Answer:

    1 -> Option A
  4. Quick Check:

    2 added - 1 removed = 1 [OK]
Quick Trick: Count pushes minus removes for length [OK]
Common Mistakes:
MISTAKES
  • Forgetting removeAt reduces length
  • Assuming removeAt(0) removes last item
  • Counting pushes only without removals

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes