decodeURIComponent: Main Tips
- This function is used to decode URI components.
- The decodeURIComponent() function is useful when you want a URL encoded using
encodeURIComponent()to become functional again.
What decodeURIComponent Is
decodeURIComponent() function is used to decode URI components. In other words, it is useful when you want a quick function for a URL decode. The abbreviation URI refers to a URI.js library used to manage URLs.
var encode = encodeURIComponent(string); var decode = decodeURIComponent(encode);
Tip: To encode URI components, use encodeURIComponent() function.
As you can see, you should not have any issues when handling decodeURIComponent parameters. The only feature to bear in mind is that the URI parameter must be included. In other words, the function won't know which URI to decode if you won't specify the previous URI, created with encodeURIComponent.
In the example provided above, you have seen the same URI, both encoded and decoded. Review it again to see and understand the differences. Grasp them, memorize the syntax, and you're good to go!