Tuesday, September 24, 2024
Google search engine
HomeLanguagesJavascriptJavaScript unescape() Function

JavaScript unescape() Function

Prerequisite: JavaScript escape() Function

The Javascript unescape() function in JavaScript takes a string as a parameter and uses it 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)

Parameters: This function accepts a single parameter as mentioned above and described below:

  • string: This parameter holds the string that will be decoded. 

Return value: This function returns a decoded string. 

Note: This function only decodes the special characters, this function is deprecated. 

Example 1: In this example, we will decode a simple encoded content using the unescape() function.

javascript




// Special character encoded with
// escape function
console.log(unescape("Geeks%20for%20Geeks%21%21%21"));
  
  
// Print encoded string using escape() function
// Also include exceptions i.e. @ and .
console.log(unescape("To%20contribute%20articles%20contact" +
    "%20us%20atreview-team@geeksforgeeks.org"));


Output:

Geeks for Geeks!!!
To contribute articles contact us at 
review-team@geeksforgeeks.org

More example codes for the above function are as follows: 

Example 2: In this example, we will decode a simple encoded content using the unescape() function.

javascript




// Special character encoded with
// escape function
let str = escape("Geeks for Geeks!!!");
console.log("Encoded : " + str);
  
// unescape() function
console.log("Decoded : " + unescape(str))
  
// The exception
// @ and . not encoded.
str = escape("To contribute articles contact us" +
    "at review-team@geeksforgeeks.org")
console.log("Encoded : " + str);
  
// unescape() function
console.log("Decoded : " + unescape(str))


Output:

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

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

Exceptions: @ – + . / * _ 

We have a complete list of Javascript Functions, to check those please go through Javascript Function Complete reference article.

Supported Browsers: 

  • Google Chrome 1 and above
  • Edge 12 and above
  • Internet Explorer 3 and above
  • Mozilla Firefox 1 and above
  • Safari 1 and above
  • Opera 3 and above

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments