Javascript Immutable

Javascript Immutable

An Immutable value cannot be changed without creating a new instance. In JavaScript all primitive types are  Immutable. Once a primitive type is created is value can only be reassigned but never changed.

Benefits

Some reasons you may want to use  an Immutable value are:

Predictable

Unexpected side effects may occur when with mutation. Unexpected side effects can make for challenging bugs to hunt down. Using immutability keeps things simple and easier to understand for current and future developers.

Performace

Immutable objects can make use of structural sharing to reduce memory overhead.Internally structures are shared andreduce memory usage garbage collection.


Share Tweet Send
0 Comments
Loading...