Bird
0
0

What will be logged to the console after this code runs?

medium📝 Predict Output Q4 of 15
Angular - HTTP Client
What will be logged to the console after this code runs?
this.http.get('https://api.example.com/data').subscribe(data => console.log(typeof data));
A'object'
B'string'
C'undefined'
D'number'
Step-by-Step Solution
Solution:
  1. Step 1: Understand HttpClient GET response type

    HttpClient automatically parses JSON responses into JavaScript objects.
  2. Step 2: Determine typeof parsed data

    Since data is parsed JSON, its type is 'object' in JavaScript.
  3. Final Answer:

    'object' -> Option A
  4. Quick Check:

    HttpClient GET returns parsed JSON as object [OK]
Quick Trick: HttpClient parses JSON to object automatically [OK]
Common Mistakes:
MISTAKES
  • Expecting string instead of object
  • Assuming undefined response
  • Thinking response is a number

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes