Skip to content
Justice Tech School

String Basics

Strings use single, double or backtick quotes. Use escape sequences such as \n and \" inside. length gives the number of UTF-16 units and indexes start at 0.

Example
const s = "Hello";
console.log(s.length, s[0], s.at(-1));
console.log("Line1\nLine2");
console.log('She said "hi"');

Exercise

Length of a string.

s.

Quiz Test

Which index is the first character?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.