Utilizor
Contact Us

Escape Characters

Using backslashes to escape characters.

Escape Characters

Because strings must be written within quotes, JavaScript will misunderstand this string:

let text = "We are the so-called "Vikings" from the north.";

The solution to avoid this problem, is to use the backslash escape character.

The backslash (\) escape character turns special characters into string characters:

  • \': Single quote
  • \": Double quote
  • \\: Backslash

Example

let text = "We are the so-called \"Vikings\" from the north.";