Cover Image for JavaScript Special Characters
200 views

JavaScript Special Characters

JavaScript allows the use of special characters within strings and regular expressions. Here are some commonly used special characters in JavaScript:

  1. Backslash (): Used as an escape character to represent special characters or sequences. For example, \n represents a newline character, \t represents a tab character, and \" represents a double quote character within a string.
  2. Single Quote (‘) and Double Quote (“): Used to delimit string literals. You can use either single quotes or double quotes to define strings in JavaScript.
  3. Newline (\n): Represents a line break or a new line character. It is commonly used within strings to create multi-line text.
  4. Tab (\t): Represents a horizontal tab character. It is often used within strings to create an indentation effect.
  5. Carriage Return (\r): Represents a carriage return character. It is commonly used in conjunction with newline characters (\r\n) to represent line breaks in Windows-style text.
  6. Backspace (\b): Represents a backspace character. It is used to remove the previous character from a string.
  7. Null (\0): Represents the null character. It is used to terminate strings in some situations.
  8. Unicode Escape (\uXXXX): Represents a Unicode character using its hexadecimal code point. For example, \u00A9 represents the copyright symbol “©”.

These are just a few examples of special characters in JavaScript. It’s important to understand their usage and how to properly escape or include them within strings or regular expressions.

YOU MAY ALSO LIKE...

The Tech Thunder

The Tech Thunder

The Tech Thunder


COMMENTS