Search⌘ K

Strings as Set of Characters

Explore how strings in JavaScript can be viewed as arrays of characters, each identified by an index. Learn to access individual characters using bracket notation and utilize loops like for and for-of to iterate over all characters in a string. This lesson builds foundational skills for manipulating and navigating strings effectively in your JavaScript programs.

Identifying a particular character

You may think of a string as an array of characters. Each character is identified by a number called an index, just as it does for an array. The same golden rules apply:

  • The index of the first character in a string is 00
...