Immutability
Primitive
Primitives, like strings and numbers, are immutable by default
let greet = "Hello";
greet += "World";
console.log(greet); // Hello worldEven if it is tried to be changed, new value with different memory address will be created instead of changing its original value

For function call , primitive input is immutable
Array & Object
Array and object are mutable

For function call , they are mutable
However, it is recommended to use immutable pattern for best practice to prevent from any side effect
Last updated
Was this helpful?