...

/

What Is Immutability?

What Is Immutability?

Learn the basics of immutability.

We'll cover the following...

Let’s define what the word mutation means. There are two types of variables in JavaScript: Those copied by value and those passed by reference. Primitive values such as numbers, strings, and Booleans are copied when you assign them to other variables, and a change to the target variable will not affect the source:

Press + to interact
let string = "Hello";
let stringCopy = string;
stringCopy += " World!";
console.log(string);
console.log(stringCopy);

In ...