在Firebug控制台中的对象 [英] Objects in Firebug console

查看:138
本文介绍了在Firebug控制台中的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我发布的一个问题的扩展。

This is an extension of a question I have posted here.

I'm having trouble manipulating js Objects, and I think it has something to do with scope or how the Objects are populated. I'm trying to use Firebug to get to the bottom of the issue, and did find one discrepancy that I can't explain. Does anyone know why sometimes Console will show an object like this:

Where it shows the contents of the Object

And sometimes like this:

Where it looks as if the Object is empty

However, the object isn't empty - when I click on the Object { } in the above screenshot, I'm taken to the DOM inspector, which sure enough shows the contents of that object:

Needless to say, it works the first way (in which I hard-coded the object's keys/values) but not the second way (in which they are dynamically added). I'm thinking if I can figure out why Console displays these two seemingly similar Objects differently, I may be able to get the bottom of the problem in my code. And I apologize if asking a similar question twice is bad form, but I figured this is a Firebug-specific question and the other is javascript related...

解决方案

SOLVED Really quite simple in retrospect, and I think @amnotiam was on to the right track with his last comment. What is happening is that I'm calling console.log() after the Object is created, but before any values have been added. By the time I click on it to inspect it in the DOM, all the values have been added.

More details on the answer to original post HERE.

这篇关于在Firebug控制台中的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆