Bird
0
0

What will be the output of this Node.js code?

medium📝 Predict Output Q5 of 15
Node.js - URL and Query String Handling
What will be the output of this Node.js code?
const decoded = decodeURIComponent('Hello%20World%21');
console.log(decoded);
AHello%20World%21
BHello World!
CHello World%21
DHello%20World!
Step-by-Step Solution
Solution:
  1. Step 1: Understand decodeURIComponent behavior

    It converts percent-encoded sequences like %20 to space and %21 to '!'.
  2. Step 2: Decode the string

    'Hello%20World%21' becomes 'Hello World!'.
  3. Final Answer:

    Hello World! -> Option B
  4. Quick Check:

    decodeURIComponent output = decoded readable string [OK]
Quick Trick: decodeURIComponent converts %20 to space and %21 to ! [OK]
Common Mistakes:
  • Expecting encoded string as output
  • Confusing decodeURI with decodeURIComponent
  • Not decoding special characters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes