Javascript Reference - JavaScript escape() Function








The escape() function was deprecated in JavaScript version 1.5. Use encodeURI() or encodeURIComponent() instead.

Browser Support

escape Yes Yes Yes Yes Yes

Syntax

escape(string)

Parameter Values

Parameter Description
string Required. The string to be encoded




Return Value

A String type value representing the encoded string.

Example

The following code shows how to Encode a string.


<!DOCTYPE html>
<html>
<body>
<script>
    document.write(escape("abc!"));
</script>
</body>
</html>

The code above is rendered as follows: