JavaScript escape() Function Last Updated : 13 Jan, 2023 Comments Improve Suggest changes Like Article Like Report 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. javascript <script> // Special character encoded with // escape function console.log(escape("Geeks for Geeks!!!")); // Print encoded string using escape() function // Also include exceptions i.e. @ and . console.log(escape("To contribute articles contact"+ " us at [email protected]")); </script> 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. javascript <script> // Special character encoded with // escape function console.log(escape("Geeks for Geeks!!!")); // Print encoded string using escape() function // Also include exceptions i.e. @ and . console.log(escape("A Computer Science Portal")); </script> 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. javascript <script> // Special character encoded with // escape function console.log(escape("GeeksforGeeks")); // Print encoded string using escape() function // Also include exceptions i.e. @ and . console.log(escape("A#Computer-Science"+ "%Portal@for*Geeks")); </script> 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 aboveInternet Explorer 3 and aboveEdge 12 and aboveMozilla Firefox 1 and aboveSafari 1 and aboveOpera 3 and above Comment More infoAdvertise with us Next Article JavaScript escape() Function S ShivamKD Follow Improve Article Tags : JavaScript Web Technologies Similar Reads Underscore.js _.escape() function Underscore.js _.escape() function is used to escape a special character string from inserting into HTML. Some of the strings that get escape are "&", ">", "<", "''", etc. Note: Some special files are needed to be included while using this code directly in the browser. It is very necessary 1 min read Less.js String escape() Function Less.js is a simple CSS pre-processor that facilitates the creation of manageable, customizable, and reusable style sheets for websites. It is preferable since CSS is a dynamic style sheet language. LESS can be utilized by many different browsers because it is versatile. Web browsers can only use CS 3 min read JavaScript unescape() 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(). Note: The unescape() function is depreca 2 min read JavaScript - Escape a String These are the following ways to Escape a String in JavaScript:1. Using BackslashesThe most straightforward way to escape characters is by using backslashes (\). This method allows you to include special characters like quotes (" or '), backslashes, and control characters within a string.JavaScriptle 1 min read Difference between unescape() and escape() functions in JavaScript In this article, we will learn about the escape() & unescape() functions in JavaScript. We will understand the purpose of using both these functions through the example. Later in this article, we will discuss the difference between escape() & unescape() functions. Let's discuss the escape() 4 min read JavaScript encodeURI(), decodeURI() and its components Functions The encodeURI() and decodeURI() functions in JavaScript are used to handle URI (Uniform Resource Identifier) encoding and decoding. They ensure that URIs are properly formatted for web usage, converting characters that may cause issues into a valid, encoded format.1. encodeURI() FunctionThe encodeUR 2 min read JavaScript String charCodeAt() Method The JavaScript str.charCodeAt() method returns a Unicode character set code unit of the character present at the index in the string specified as the argument. The index number ranges from 0 to n-1, where n is the string's length.Syntax:str.charCodeAt(index)Parameters: This method accepts a single p 3 min read Lodash _.escape() Method Lodash _.escape() method is used to convert the characters "&", "<", ">", '"', and "'" of the given string into their corresponding HTML entities. Syntax:_.escape([string='']);Parameter:string: This parameter holds the string containing escape characters.Return Value: This method returns t 1 min read When we use Escape Instead of encodeURI / encodeURIComponent in JavaScript ? A URL consists of many characters, both special and unique. Unique characters include those that are not plain standard such as spaces etc. So it means that we need to encode characters in UTF-8. So if we have a string such as: "https://www.gfg.com/what is html?" then UTF-8 will encode it as "https: 3 min read JS Escape Sequence | HTML Entity There are certain symbols in HTML that always seem to break your program. These include math, currency, greek alphabet symbol, etc. Either they are not available in your keyboard or browser to interpret them differently to what you intended. So here is the list to HTML code for different symbol and 3 min read Like