InterviewHubPRO
Section Overview
Q216

Question 216 of 521

Part 4: Prototypes, Object Methods & Event Loop (174 - 253)

41%
JavaScript Internals (521 Qs)•Part 4: Prototypes, Object Methods & Event Loop (174 - 253)

How do you decode an URL

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

javascript
  var uri = "https://mozilla.org/?x=шеллы";
  var encoded = encodeURI(uri);
  console.log(encoded); // https://mozilla.org/?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B
  try {
    console.log(decodeURI(encoded)); // "https://mozilla.org/?x=шеллы"
  } catch (e) {
    // catches a malformed URI
    console.error(e);
  }