I\'d like to update my JSON
value based on selection.
So for that I have simply update my json value as data.childShow = true
.
No
Try this thing in console it might solve your confusion. Add an object
like let data = { childShow: false }
. Then log it in console. Do not expand right now. Now change the value of data.x = true;
in expanded value but it also has childShow=false
in first line. Now expand console log value. You can see it is displaying childShow = true
. So it might be fetching current values when we expand.
You can also log childShow
and check what exactly values hold by data.childShow
. Like in below snippet. It will show you when you do console.log(data.childShow);
first time it will show false
and second time it will show true
which is as expected
.
Try with below like. 1.
Open console of browser. 2.
Click on Run Code Snippet. 3.
Expand object in console.
const data = {
childShow: false,
}
console.log(data);
console.log(data.childShow); // Output false
data.childShow = true;
console.log(data);
console.log(data.childShow); // Output true