JavaScript | unescape() with examples

Prerequisite: JavaScript | escape()

The unescape() function in JavaScript takes a string as a parameter and use to decode that string encoded by the escape() function. The hexadecimal sequence in the string is replaced by the characters they represent when decoded via unescape().

Syntax :

unescape(string)
filter_none

edit
close

play_arrow

link
brightness_4
code

<script>
  
// Special character encoded with
// escape function
var str = escape("Geeks for Geeks!!!");
document.write("Encoded : " + str);
  
// New Line
document.write("<br>");
  
// unescape() function
document.write("Decoded : " + unescape(str))
  
// New Line
document.write("<br><br>");
  
// The exception
// @ and . not encoded.
str = escape("To contribute articles contact us"
                "at contribute@geeksforgeeks.org")
document.write("Encoded : " + str);
  
// New Line
document.write("<br>");
  
// unescape() function
document.write("Decoded : " + unescape(str))
  
</script>

chevron_right


Output :

Encoded : Geeks%20for%20Geeks%21%21%21
Decoded : Geeks for Geeks!!!

Encoded : To%20contribute%20articles%20contact%20us%20at%20contribute@geeksforgeeks.org
Decoded : To contribute articles contact us at contribute@geeksforgeeks.org


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.