I think strings are immutable, regardless of whether they are items in an array or not. What you have done is replace an item in the array, which was a string, with a new item, which just happens to be a different string, You haven’t altered the original string, you’ve only altered array items both of which happened to be strings.
Related topics
Topic | Replies | Views | Activity | |
---|---|---|---|---|
Understand String Immutability 2018 | 3 | 805 | February 2, 2021 | |
String Immutability. Why am I doing wrong here? | 6 | 488 | January 25, 2021 | |
Strings and const variables | 3 | 1102 | December 11, 2022 | |
Understand String Immutability extra help | 2 | 327 | January 25, 2021 | |
Please help me understand this! Basic JavaScript - Understand String Immutability | 12 | 980 | June 4, 2023 |