JavaScript escape() Function

Definition and Usage

In JavaScript 1.5, the escape() function is not recommended. Please use encodeURI() Or encodeURIComponent() Instead of.

escape() The function encodes the string.

This function makes the string portable, so it can be transmitted through any network to any computer that supports ASCII characters.

This function encodes special characters, but the following characters are excluded: * @ - _ + . /

Example

Encoded String:

document.write(escape("Need tips? Visit CodeW3C.com!"));

Try it yourself

Syntax

escape(string)

Parameter Value

Parameter Description
string The string to be encoded.

Technical Details

Return Value: String, representing the encoded string.

Browser Support

Function Chrome Edge Firefox Safari Opera
escape() Support Support Support Support Support