开发者

Why does the firebug console keep saying "undefined" when I enter a json object?

开发者 https://www.devze.com 2022-12-11 22:00 出处:网络
Here is a short transcript from my firebug console: >>> var a = {\"name\": \"bob\"}; >>> a

Here is a short transcript from my firebug console:

>>> var a = {"name": "bob"};
>>> a
undefined name=bob
>>> a.name
"bob"
>>> b = 10
10
>>> b
10

Why does firebug print "undefined"? Why on a and n开发者_运维知识库ot b?

Inquiring minds want to know.


Which version are you using? To me it prints

>>> var a = {"name":"bob"};
>>> a
{ name=bob }

I'm using Firebug 1.4.5/Firefox 3.5.5.


After you've created var a = {"name": "bob"}; in the Console, you can always switch over to Script -> Watch and then enter your a there to get a nice representation of your object/variable/element/whatever.

What's odd is that when I do exactly what you did, I don't see Undefined name=bob, I see Object name=bob (which is probably what you were expecting, and hence your question).

Good luck!


you might be using a variable that is used in the json library. Try choosing a variable that isn't very common.

0

精彩评论

暂无评论...
验证码 换一张
取 消