Javascript String immutable feature

Introduction

Javascript strings are immutable.

Once they are created, their values cannot change.

To change its value, the original string must be destroyed and the variable will be filled with another string containing a new value:

let lang = "Java"; 
lang = lang + "Script"; 

Here, the variable lang is defined to contain the string "Java".

On the next line, lang is redefined to combine "Java" with "Script".




PreviousNext

Related