DEV Community

Discussion on: LEVEL UP with JavaScript! LVL 6

Collapse
lukeshiru profile image
LUKESHIRU

Yes and no. Strings are immutable:

const example = "foo";
example[0] = "x"; // This does nothing
example === "foo"; // So this is true
Enter fullscreen mode Exit fullscreen mode

But as you mentioned, the example @devcronin gave with undefined, doesn't make any sense. console.log always returns undefined, so that has nothing to do with mutation. Also the example is not actually "mutating" name, is just assigning a new value to it.

Collapse
devcronin profile image
DevCronin Author

I am a Jr dev and believe this was just a mistake on my part. I do my best to ensure I keep my content accurate. Thank you both for replying and pointing out my error.