views:

98

answers:

2

So, I'm attempting to access the content of an object and for the life of me can't figure out why I can't. I'm starting to believe that the object doesn't have the properties that Firebug indicates that it does. More likely than that I'm just not using the right syntax to access them.

Give the following function:

function(userData) {
    console.log(userData);   // statement 1
    console.log(userData.t_nodecontent); // statement 2
}

Which generates the following FireBug output for statement 1

image

and undefined for statement 2. (Note: Originally incorrectly indicated that I was seeing unknown)

Is there something obvious that I'm overlooking in the way I'm attempting to reference the value of t_nodecontent? I'm at a loss :(

A: 

Try this and write output:

for(var key in userData){
   console.log(key, userData[key]);
}
blow
+2  A: 

unknown means that its a Host Object, like the ones provided by ActiveXObject in IE.

If there had been no such property, you would have seen undefined

So you are accessing its property, it's just has a type not defined by ECMAScript.

Sean Kinsey
ActiveX? In Firefox?
KennyTM
Seems a weird case... I've only seen `"unknown"` as the result of `typeof` operator in some properties of the host objects you mention, but only on **IE**, seems that the OP is using Firefox, and he is just trying to access the property... unusual...
CMS
@Kenny, hehe, duh! :)
Sean Kinsey
@CMS, who knows what `console.log` does in the background, we all know that it doesn't just do `toString()`
Sean Kinsey
I made a mistake :( It actually says undefined. Will edit the post accordingly.
Matty
so, If it shows up in Firebug, but I get an undefined when trying to reference it, how does FireBug find it?
Matty