Recall & Review
beginner
What is URL encoding and why is it important?
URL encoding converts characters into a format that can be transmitted over the internet. It replaces unsafe ASCII characters with a '%' followed by two hexadecimal digits. This ensures URLs are valid and data is correctly interpreted.
Click to reveal answer
beginner
Which Node.js global functions are used to encode and decode URLs?
encodeURIComponent() is used to encode a URI component by escaping characters. decodeURIComponent() reverses this process, decoding the encoded URI component back to its original form.
Click to reveal answer
intermediate
What is the difference between encodeURI() and encodeURIComponent() in Node.js?
encodeURI() encodes a full URI but leaves characters like '/', ':', and '?' intact. encodeURIComponent() encodes every character that is not a letter, number, or one of a few special characters, making it safer for encoding query parameters.
Click to reveal answer
beginner
How do you decode a URL string in Node.js?
Use decodeURIComponent() to convert an encoded URL component back to its original string. For example, decodeURIComponent('%20') returns a space character.
Click to reveal answer
beginner
Why should you encode query parameters in URLs?
Query parameters may contain special characters like spaces or '&' that can break the URL or cause errors. Encoding ensures these characters are safely transmitted and correctly interpreted by servers and browsers.
Click to reveal answer
Which function should you use to encode a query parameter in Node.js?
✗ Incorrect
encodeURIComponent() safely encodes query parameters by escaping all characters that could break the URL.
What does decodeURIComponent('%20') return?
✗ Incorrect
The encoded '%20' represents a space character, so decoding it returns a space.
Which characters does encodeURI() NOT encode?
✗ Incorrect
encodeURI() leaves URI reserved characters like '/', ':', and '?' unencoded to preserve URI structure.
Why is URL encoding necessary?
✗ Incorrect
Encoding replaces unsafe characters with safe codes so URLs work correctly across the internet.
Which function reverses the encoding done by encodeURIComponent()?
✗ Incorrect
decodeURIComponent() decodes strings encoded by encodeURIComponent(), restoring original characters.
Explain how and why you would encode and decode URLs in a Node.js application.
Think about sending data in URLs and how special characters affect them.
You got /4 concepts.
Describe the difference between encodeURI() and encodeURIComponent() with examples.
Consider when you want to encode a full link versus just a piece of it.
You got /4 concepts.