I have an object
with nested objects
like in the following way.
var g = {
"steps": [{
"location": [{
"a": "1"
}, {
"a": "2"
}]
}]
};
I created duplicate object using Object
like in the following way.
var h=Object.create(g);
The problem was,If I Modify anything in h
,g
also reflecting.How can I prevent this.I tried with underscore
function(clone
).
modified:
h["steps"][0]["location"][0]["a"]="3"
After modify:
g
looks like
h
looks like
Even If I modify anything in h
,g
should not be reflect.
can anyone help me.
Thanks.