Chrome displays different object contents on expand

后端 未结 4 1927
名媛妹妹
名媛妹妹 2020-12-04 02:27

Why does Chrome display two differing datasets depending on if you have the object view expanded?

In contracted view, my object has two properties:

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 02:54

    @Gideon Pyzer is right. the properties were caculated and added after expanding the object in the console.

    Just add one line code above your debug code and reopen the chrome dev tool, you will see the differences.

    obj = Object.freeze(obj);  //add this line before your console.log
    console.log(obj);
    

    Before:

    After:

    one similar question of mine: Why can't I access the attr of the javascript object shown in chrome dev tool

提交回复
热议问题