> I'm very confused. I'm trying to iterate through the elements of an 
> array by using the jQuery.each() function. Take a look at the code below:
>
> $.each(['vendors', 'models', 'views'], function()
> {
>     console.log(this, typeof(this));
> });
>
> I would expect firebug to produce an output like this:
>
> "vendors" "string"
> "models" "string"
> "views" string"
>
> Instead I get this:
>
> ["v","e","n","d","o","r","s"] "object"
> ["m","o","d","e","l","s"] "object"
> ["v","i","e","w","s"] "object"
>
> Which is why I am confused. Those objects look like arrays in the 
> console, but when trying this.join('') to convert them into a string 
> again I get the error that this function is not defined, indication 
> that those this objects are in fact no arrays but something else. 
> However using alert(this) will make them look as if they were strings.
>
> Have I gone crazy? Is there a bug in firebug? Or am I just incredibly 
> stupid?
>
> I'd appreciate any form of help, regardless of eventual truths about 
> the state my sanity ; ).
To my experience this strange behaviour is a firebug (<- pun intended). 
Ahem, a firebug bug. Firebug thinks your String is an array (it has a 
length property) and therefore prints it as an array, though it does 
that only in special cases.

-- 
Jörn Zaefferer

http://bassistance.de


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to