Benefits of using immutable objects
Introduction Hello Dev, is good to have you on my blog. In today's article, I will be talking about the benefits associated with using immutable object or data. Most of the time even when the situation does not demand using mutable object we still use them, whilst in the genuine case of using immutable we don't. I am hoping after reading this piece, you would know when to use mutable and when to use immutable, so as to have an efficient system running. Immutable data in computer programming refers to data that cannot be modified or changed after its creation. Once immutable data is created, its value remains fixed throughout its lifetime. Any attempt to modify the data will result in the creation of a new data instance with the desired changes, leaving the original data unchanged. Sample Code : // JavaScript // Using primitive data types (immutable) let number = 42; // A primitive number let text = "Hello"; // A primitive string // Attempting to modify t...