Chrome js debug - two different values at the same time [duplicate]

六眼飞鱼酱① 提交于 2019-12-29 09:41:56

问题


In the screenshot below you will see a console.log print of an object that has a theme field. But this field at the same time has and doesn't have a value. How to interpret this? My intent is to assign the value.


回答1:


When a property is filled asynchronously, or parent object is console logged before it's property is filled with value, such the behaviour will occur.

var obj = {};

// here when checking the dev tools obj = {}

ajax('url', function() {
 obj.a = 5
 // here when checking the dev tools obj = { a : 5}
})



回答2:


Logging objects in Chrome is a bit tricky. If you do a log of the entire object and then change a property of the object, it always shows the latest value for the property.

Try logging Object.theme instead of logging the entire object and you will see the difference.




回答3:


There is small blue icon on your screenshot, hover it and you get the answer to your question.



来源:https://stackoverflow.com/questions/38394673/chrome-js-debug-two-different-values-at-the-same-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!