[removed] JSON key values not updating on request

前端 未结 1 1793
梦毁少年i
梦毁少年i 2021-01-29 12:41

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

相关标签:
1条回答
  • 2021-01-29 13:48

    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

    0 讨论(0)
提交回复
热议问题