VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-escape-function/

⇱ JavaScript escape() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript escape() Function

Last Updated : 11 Jul, 2025

The Javascript escape() function takes a string as a parameter and encodes it so that it can be transmitted to any computer in any network which supports ASCII characters.

Note:

escape(): This function was used to encode special characters in a string, but it has been replaced by the encodeURI() and encodeURIComponent() functions, which provide more options and better support for different character encodings.

Syntax:

escape(string)

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

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

Return value: This function returns an encoded string. 

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

Exceptions: @ - + . / * _

Below is an example of the escape() function.

Example: In this example, we will simply encode a string with some signs using the JavaScript escape() Function.

Output:

Geeks%20for%20Geeks%21%21%21
To%20contribute%20articles%20contact%20us%20atcontribute
@geeksforgeeks.org 

More example codes for the above function are as follows: 

Example 1: In this example, we will simply encode a string with some signs using the JavaScript escape() Function.

Output:

Geeks%20for%20Geeks%21%21%21
A%20Computer%20Science%20Portal

Example 2: In this example, we will simply encode a string with some signs using the JavaScript escape() Function. 

Output:

GeeksforGeeks
A%23Computer-Science%25Portal@for*Geeks

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
  • Internet Explorer 3 and above
  • Edge 12 and above
  • Mozilla Firefox 1 and above
  • Safari 1 and above
  • Opera 3 and above
Comment
Article Tags: