Chrome displays different object contents on expand

后端 未结 4 1932
名媛妹妹
名媛妹妹 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 03:15

    The object you see in the console is a snapshot of the object at a particular point in time - the time when you logged it. When you expand the object, it will evaluate the properties again.

    In the example below, I have created an object with two array properties. I logged it the console, and then I added a third property, c to it.

    Only the first two properties are showing still, even though I just added a third property. After expanding the object in the console, I can see the third one. It is the latest state of the object.

    If you hover over the little blue i icon, it explains what it has done:

    Value below was evaluated just now.

提交回复
热议问题