Premium lesson

Working With Strings in JavaScript I

JavaScript·3 min read·Mar 17, 2025

In JavaScript, a string literal, string of characters, or simply string, is a primitive data type that represents a sequence of characters, such as letters, digits, symbols, or spaces, enclosed in single quotes '', double quotes "", or backticks ``.

It is used for storing textual information, text manipulation, and representing data in a human-readable format.

Accessing individual characters

To access the individual characters of a string, you can use the square brackets syntax []:

string[index]

Where:

  • string is a string of characters.
  • index is the index (or position) of the character you want to access within the string. It can either be a user-defined number or a variable containing a computed number.

Notes:

  • The index of the first character in a string is 0.
  • When accessing an "out of bounds" index, the expression will result in undefined.