Bird
0
0

What will the following Node.js code output?

medium📝 component behavior Q4 of 15
Node.js - HTTP Module
What will the following Node.js code output?
const querystring = require('querystring');
const parsed = querystring.parse('theme=dark&font=large');
console.log(parsed.theme);
A"large"
B"dark"
Cundefined
Dnull
Step-by-Step Solution
Solution:
  1. Step 1: Parse the query string

    The string 'theme=dark&font=large' is parsed into an object: { theme: 'dark', font: 'large' }.
  2. Step 2: Access the 'theme' property

    Accessing parsed.theme returns the string 'dark'.
  3. Final Answer:

    "dark" -> Option B
  4. Quick Check:

    Parsed object keys match query keys [OK]
Quick Trick: Parsed keys map directly to object properties [OK]
Common Mistakes:
  • Confusing property names
  • Expecting the entire object instead of a property
  • Assuming undefined for existing keys

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes