Bird
0
0

Given this Angular code snippet:

medium📝 state output Q13 of 15
Angular - State Management
Given this Angular code snippet:
const count = signal(0);
count.set(5);
console.log(count());

What will be printed in the console?
A5
Bundefined
C0
DError
Step-by-Step Solution
Solution:
  1. Step 1: Understand signal initialization and update

    The signal count starts at 0, then is updated to 5 using count.set(5).
  2. Step 2: Evaluate the console.log output

    Calling count() returns the current value, which is 5 after the update.
  3. Final Answer:

    5 -> Option A
  4. Quick Check:

    Signal value after set(5) = 5 [OK]
Quick Trick: signal() returns current value when called like a function [OK]
Common Mistakes:
  • Thinking count() returns initial value 0
  • Expecting undefined because of missing parentheses
  • Assuming set() does not update the value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes