Bird
0
0

Consider this code snippet:

medium📝 component behavior Q5 of 15
Node.js - HTTP Module
Consider this code snippet:
const querystring = require('querystring');
const parsed = querystring.parse('x=5&x=10&x=15');
console.log(parsed.x);
What will be logged to the console?
A["5", "10", "15"]
B"15"
C"5"
Dundefined
Step-by-Step Solution
Solution:
  1. Step 1: Understand repeated keys behavior

    The 'querystring' module keeps only the last value for repeated keys.
  2. Step 2: Analyze the input

    For 'x=5&x=10&x=15', the last value for 'x' is '15'.
  3. Final Answer:

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

    Repeated keys overwrite previous values [OK]
Quick Trick: Last repeated key value is retained [OK]
Common Mistakes:
  • Expecting an array of values
  • Assuming first value is kept
  • Thinking all values are concatenated

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes