简体   繁体   中英

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

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 not 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM