What are Escape Characters in JavaScript ? Last Updated : 07 May, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report Escape Characters(Backslash) are the symbol used to begin an escape command in order to execute some operation. Escape characters are characters that are used when working with special characters like single quotes, and double quotes, To print these characters as it is, including the backslash ‘\’ in front of them. Syntax: For single quotes: \’ (backslash followed by single quote) For double quotes: \” (backslash followed by double quotes) List of escape characters available in javascript: Escape characterResult\b This character is used to give a backspace\f This character is used for form feed\n This character is used to give a new Line\r This character is used for carriage Return\t This character is used for horizontal Tabulator\v This character is used for vertical Tabulator Example 1: In this example, we are using single quotes \' and double quotes\" JavaScript let str = "Geeks \'for\' Geeks"; console.log(str); let str2 = "Geeks \"for\" Geeks"; console.log(str2); Output: Geeks 'for' Geeks Geeks "for" Geeks Example 2: In this example, we will use backlash in javascript. HTML <!DOCTYPE html> <html> <body> <h2>Escape character in Javascript</h2> <p id="result"></p> <script> let text = `This example shows the use of a backslash character in Javascript. The character \\ is called backslash.`; document.getElementById("result").innerHTML = text; </script> </body> </html> Output: Example 3: Here by using backslash we will break our string in javascript. HTML <!DOCTYPE html> <html> <body> <h1>Escape characters in Javascript</h1> <h2>Breaking the string using backslash</h2> <p id="result"></p> <script> document.getElementById("result").innerHTML = "Hello \world! \from GEEKSFROMGEEKS"; </script> </body> </html> Output: Comment More infoAdvertise with us Next Article JavaScript - Insert Character in JS String G geekwriter2024 Follow Improve Article Tags : JavaScript Web Technologies Similar Reads What are the encodeURI() and decodeURI() in JavaScript ? URLs and URIs are designed to locate/identify resources available over the internet, anything that uniquely identifies a resource is its URI, such as id, name. A URL specifies a resource and its access protocol. All URLs are URIs, but not all URIs are URLs. URI can only have certain characters from 3 min read Remove a Character From String in JavaScript In JavaScript, a string is a group of characters. Strings are commonly used to store and manipulate text data in JavaScript programs, and removing certain characters is often needed for tasks like:Removing unwanted symbols or spaces.Keeping only the necessary characters.Formatting the text.Methods t 3 min read Get Unicode Character Value in JavaScript Here are various ways to get Unicode character values in JavaScript 1. Using charCodeAt() to Get Unicode ValuesThis code defines a string letter containing the character "A". It then uses the charCodeAt() method to get the Unicode value of the first character (index 0) and logs the result, which is 5 min read How to escape & unescape HTML characters in string in JavaScript? Escaping and unescaping HTML characters is important in JavaScript because it ensures proper rendering of content, preventing HTML injection attacks and preserving text formatting when displaying user-generated or dynamic content on web pages. Escape HTML Characters< : <> : >" : 3 min read JavaScript - Insert Character in JS String In JavaScript, characters can be inserted at the beginning, end, or any specific position in a string. JavaScript provides several methods to perform these operations efficiently.At the BeginningTo insert a character at the beginning of a string, you can use string concatenation or template literals 1 min read How to Escape Characters in XML ? Escaping characters in XML is important because it ensures that special characters like <, >, &, and ", which have special meanings in XML, are properly encoded as entities like <, >, &, ", respectively. There are several approaches to escape characters in XM 2 min read Like