JavaScript escape() Function
JavaScript Global Functions
Definition and Usage
The escape() function encodes a string so that it can be read on all computers.
This method does not encode ASCII letters and digits, nor does it encode these ASCII punctuation marks: * @ - _ + . /. All other characters are replaced by escape sequences.
Tip: Use unescape() The method decodes a string.
**Note:** The escape() function has been removed from the Web standard, so try to avoid using this function; you can use encodeURI or encodeURIComponent instead.
Syntax
escape(string)
| Parameters | Description |
|---|---|
| string | Required. The string to be escaped or encoded. |
Browser support





All major browsers support the escape() function
Tips and Notes
Note: The escape() function cannot be used to encode URIs (Uniform Resource Identifier, abbreviated as "URI"). You can use the function encodeURI() instead.
Example
Example
Use escape() to encode a string:
The example above produces the following output:
Need%20tips%3F%20Visit%20RUNOOB%21
Try it »
JavaScript Global Functions