问题
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