I am new to react and have a question about immutability in es6 to help my understanding of immutability.
For example, I know this is invalid in JSX as it is reassigning a const.
const helloWorld = 'Hello World';
helloWorld = 'Bye World';
however, this seems valid:
const helloWorld = {greeting: 'hello World'};
helloWorld.greeting = 'bye world';
In essence, the concept i'm trying to wrap my brain around is the idea that while although helloWorld
is immutable, the value it holds is not. How and why does this still represent immutability? And why would you use it in this fashion instead of using a let
variable?
Thanks and apologies for the noob question if it is as such! :)