</> Code Corner

JavaScript · JS Tutorial · Lesson 14

JS Strings

Text in quotes, length and escape characters.

Strings store text. They are written with single quotes, double quotes or backticks.

Example

<p id="demo"></p>
<script>
let text = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
let quote = "He said \"Hello\"";
let multi = `Backticks allow
multiple lines`;
document.getElementById("demo").innerHTML =
  "Length: " + text.length + "<br>" + quote + "<br>" + multi + "<br>" + text[0] + text.at(-1);
</script>
Escape Result
\" Double quote
\' Single quote
\\ Backslash
\n New line

Keep reading “JS Strings”

Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.

Chat with us 👋