Strings in JavaScript
Strings are immutable UTF-16 sequences in single, double, or backtick quotes — quote choice is style except that backticks enable interpolation. Indexing (s[0]), length, and iteration all operate on UTF-16 code units, which splits astral characters (emoji) in two — [...s] spreads by code point when that matters.
Every string method returns a new string; the original never changes. Concatenation with + is fine for a few pieces; hot loops should collect into arrays and join once instead of quadratic += chains.
Three quote styles
Single, double (interchangeable), backticks (interpolation + multiline) — pick per team style, backticks when embedding values.
Immutable always
s[0] = "X" silently fails (or throws strict) — methods like toUpperCase return fresh strings.
UTF-16 under the hood
length counts code units, so emoji count 2 — spread ([...s]) or Array.from for code-point-correct iteration.
Build efficiently
Few pieces: + is fine. Many pieces in a loop: push to an array, join("") once at the end.
let s = "hello";console.log(s.length, s[1]);console.log(s.toUpperCase(), s);Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in JavaScript yourself — building beats watching.