A JavaScript string cannot be changed after creation. An operation that appears to modify one creates a new string instead; assigning to an indexed character leaves the original unchanged. section 2.2.1
const str = 'hello'; str[0] = 'H'; // try to modify the first character fails! console.log(str); // still 'hello'
This indexed assignment does not change the string; the logged value remains 'hello'. section 2.2.1
Immutability lets V8 safely reference existing strings and supports ConsString concatenation, which can avoid copying during concatenation. But repeated concatenation in loops can make allocation and copying costly; a naïve approach can grow quadratically. Array.join() or template literals are suggested as alternatives to repeated concatenation. section 2.3 section 2.2.1





























