Bird
0
0

Given this Angular signal-based component code:

medium📝 component behavior Q13 of 15
Angular - Signals
Given this Angular signal-based component code:
const count = signal(0);
count.set(count() + 1);
console.log(count());

What will be printed in the console?
A1
B0
Cundefined
DError
Step-by-Step Solution
Solution:
  1. Step 1: Understand initial signal value

    The signal count starts at 0.
  2. Step 2: Evaluate the update expression

    count.set(count() + 1); reads current value 0, adds 1, sets new value 1.
  3. Step 3: Check the console output

    console.log(count()); prints the updated value 1.
  4. Final Answer:

    1 -> Option A
  5. Quick Check:

    Initial 0 + 1 = 1 printed = B [OK]
Quick Trick: Remember to call signal() to get value, then set() to update [OK]
Common Mistakes:
  • Forgetting to call count() to get value
  • Expecting 0 because of no visible loop
  • Confusing set() with update()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes