0
Challenge · 09Just Enough JavaScript
Strings cannot be changed
JavaScriptused in ~95% of apps
You will try to change one letter of a word, watch nothing happen, and lose twenty minutes to it. Every beginner does. Five minutes here saves you that.
Core idea. A string looks like an array of characters and behaves like one for reading. But you cannot change a letter in place. Every operation that seems to modify a string actually builds a brand new one.
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
const word = "hello"
h
0
e
1
l
2
l
3
o
4
reading works
word[1] // "e"
word.length // 5
word[0] // "h"writing does nothing
word[0] = "J";
console.log(word);
// "hello" - unchanged, NO errorThe assignment is silently ignored. No error, no change, which is why it costs people so much time.
↑ play a little first, then dig in