JS Coding Questions Logo
JS Coding Questions
#212๐Ÿ’ผ Interview๐Ÿ’ป Code

How do you decode an URL

Advertisement

728x90

The decodeURI() function is used to decode a Uniform Resource Identifier (URI) previously created by encodeURI().

javascript
1var uri = "https://mozilla.org/?x=ัˆะตะปะปั‹";
2
3var encoded = encodeURI(uri);
4
5console.log(encoded); // https://mozilla.org/?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B
6
7try {
8  console.log(decodeURI(encoded)); // "https://mozilla.org/?x=ัˆะตะปะปั‹"
9} catch (e) {
10  // catches a malformed URI
11  console.error(e);
12}

Advertisement

Responsive Ad
๐ŸŽฏ Practice NowRelated Challenge

JavaScript Coding Exercise 42

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
212of476