

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Escape characters in JavaScript
Escape characters are characters that can be interpreted in some alternate way then what we intended to. To print these characters as it is, include backslash ‘\’ in front of them. Following are the escape characters in JavaScript −
Code | Result |
---|---|
\b | Backspace |
\f | Form Feed |
\n | New Line |
\r | Carriage Return |
\t | Horizontal Tabulator |
\v | Vertical Tabulator |
\' | Single quote |
\" | Double quote |
\\ | Backslash |
Following is the code implement escape character Backslash in javaScript −
Example
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result { font-size: 18px; font-weight: 500; } </style> </head> <body> <h1>Escape characters in JavaScript</h1> <div class="result"></div> <script> let str = 'Hello World "This" is some sample \\ Text \' '; let resEle = document.querySelector(".result"); resEle.innerHTML = str; </script> </body> </html>
Output
- Related Questions & Answers
- Escape Characters in Python
- JavaScript escape()
- Ways to print escape characters in C#
- Ways to print escape characters in python
- How can we escape special characters in MySQL statement?
- How to escape all special characters for regex in Python?
- List down a list of the escape characters in C#
- How to escape characters that can be interpreted as XML markup in JSP?
- How can I escape HTML special chars in JavaScript?
- Escape sequences in Java
- Escape sequences in C
- Escape The Ghosts in C++
- Build (escape) regexp in MongoDB?
- Map numbers to characters in JavaScript
- Generate random string/characters in JavaScript?
Advertisements