JSβΊStrings & Template Literals
π€Strings & Template LiteralsbeginnerFreeJS
stringtemplate literaltagged templateUnicodeUTF-16regexpadStart
0/8 done~69 min
1
Mental model: Strings
Mental
~5 min
2
The 12 string exceptions
Exceptions
~15 min
3
Predict the output
Predict
~10 min
4
True or False
T/F
~6 min
5
Fill in the blank
Fill
~5 min
6
Fix the bug
Fix Bug
~8 min
7
Spot the bug
Spot Bug
~5 min
8
Put it together
Cement
~15 min
1 / 8Read~5 min
Mental model: Strings
Build the right picture in your head before we practice.
JavaScript strings are sequences of UTF-16 code units, not Unicode characters. Emoji and many non-Latin characters use two code units (a surrogate pair) β which is why 'π'.length === 2, and split('') can break emoji in half.
Every string operation that works on indices (length, charAt, split(''), slice) operates on UTF-16 code units. For-of and spread use the string iterator, which correctly yields code points. When you need to handle emoji or international text, always use spread or Array.from() instead of split('').
Scroll to the bottom to continue
Notes
π
Loadingβ¦
Sections
0/8 done~69 min
1
Mental model: Strings
Mental
~5 min
2
The 12 string exceptions
Exceptions
~15 min
3
Predict the output
Predict
~10 min
4
True or False
T/F
~6 min
5
Fill in the blank
Fill
~5 min
6
Fix the bug
Fix Bug
~8 min
7
Spot the bug
Spot Bug
~5 min
8
Put it together
Cement
~15 min
Notes
Notes
π
Loadingβ¦