Bird
0
0

What will be logged to the console when running this Angular code?

medium📝 Predict Output Q5 of 15
Angular - Signals
What will be logged to the console when running this Angular code?
import { signal } from '@angular/core';
const count = signal(5);
count.update(v => v + 2);
console.log(count());
A5
B7
CNaN
DError: update is not a function
Step-by-Step Solution
Solution:
  1. Step 1: Initialize signal with 5

    count starts at 5.
  2. Step 2: Use update to add 2

    update applies function v => v + 2, so value becomes 7.
  3. Step 3: Log current value

    Calling count() returns 7.
  4. Final Answer:

    7 -> Option B
  5. Quick Check:

    Signal update result = 7 [OK]
Quick Trick: Use update(fn) to change signal value based on current value [OK]
Common Mistakes:
  • Forgetting update returns new value
  • Trying to add directly without update or set

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes