I am already understand mutability of the javascript and main idea of the mutable objects, but now I wont to fashin my knowledge.
For example we need to store object with many properties. We have 2 variants:
Create mutable complex js object and not mutate it.
const object = { ... }; const newObject = Object.assingn({}, object, {someProp: newValue});
And then all old
object
will be not equal tonewObject
.Create Immutable object via some library, example with Immutable JS
const object = Immutable.fromJS({...}); Immutable.setIn(...)
And we will get completely the same result, objects will be not equal.
I already know that Immutable does not deep copy of the objects, and all not modified data will reusable via links - is it the main idea? Will immutable js variant be more performance-friendly and faster?
Or it is only semanticly better, and better to have no ability to mutate object?