JavaScript handles immutability on average. Using Immutable.js guarantees us immutability and at the same time provides a rich API with high performance. Therefore, in this article I will discuss the Immutable.js library.

Immutable

Immutability in Javascript

As I mentioned in the introduction, Javascript is not designed to work with data that is supposed to be immutable. Currently Javascript has two data types that are immutable and they are: strings and numbers. The concept of immutability in programming tells us that if we declare a data type then this data does not change directly. If we want to change some kind of data then we should create a copy of this data and on this copy we modify this particular data. In Javascript we have methods that allow us to work on objects and arrays without changing the original content, and these are methods such as map, filter, or slice. These methods create copies of the data and make changes just on this copy of the data.

 

Are you looking for a contractor working with Immutable.js ?
logo

What is immutable.js?

This is a library that helps Javascript handle immutable data structures. This means that once created, the data cannot change. This library makes it easier to maintain immutable data structures. Immutable.js does a lot of things "under the hood," which improves performance. Immutable data structures usually consume a lot of RAM because this approach requires the constant creation for new copies of objects, and by using immutable.js we are able to optimize this process.

 

Advantages of Immutability

The main advantages of immutability are predictability, performance and better mutation tracking. When working with front-end libraries, we declare a lot of state in them. We also often perform some asynchronous actions and update the original state. When the user starts performing actions: add, delete, update then the state will be very different from the initial state. Mutating the state causes side effects that can cause errors. That's why it's a good idea to use a library to help us with data immutability.

Our offer

Web development

Find out more

Mobile development

Find out more

E-commerce

Find out more

UX/UI Design

Find out more

Outsourcing

Find out more

Related articles

Show all articles