Consider I have an object name x
having value x = { a: 'abc', b: 'jkl' }
,
Now I'm assigning this object x
to new local variable y
by var y = x
.
when var y
value change with new value y.a = 'pqr', y.b = 'xyz'
, var x
object auto updates with new value { a: 'pqr', b: 'xyz' }
of var y
.
This is the good scenario but in some cases I want to prevent that. How can I achieve this?
You can find plunker code for this here