I have objects in array as
var arr = [{'name':'one','age':24},{'name':'two','age':21}]
I have assigned this array to another variable var newVar = arr
. Now I am changing value of an objects of newVar
as newVar[0].age = 18
, But change the value of object of newVar
get reflected in arr(original data)
as well. After change value in newVar
, arr
is
var arr = [{'name':'one','age':18},{'name':'two','age':21}]
I want original data should be independent of changing values of another variable holding same data. How can I get it with java script?