3 Comments
author

Hey Ankur, yes I can elaborate on that:

Immutable means that the value itself doesn't change.

Take this example:

var x = 'one'

x = x.substring(0, 1)

On line 1, JavaScript stores the string 'one' in the stack. On the second line, instead of modifying the original value in memory, it creates a new string based on the original value.

The variable x now points to the new string 'o' instead of 'one', but the original value (the string 'one') is never modified in memory.

Here's an article that clarifies this further: https://bit.ly/3HVgSkA

Does this clear things up for you?

Expand full comment

Hi, could you please explain:- Primitive values are immutable, which means that instead of changing the original value, JavaScript creates a new one.

How does this happen? Could you please explain the detailed working of this?

Thanks.

Expand full comment

Hi good work for people can you provide article on references in Javascript

Expand full comment