All pastes #928100 Raw Edit

Stuff

public text v1 · immutable
·published 2008-03-04 20:17 UTC
rendered paste body
<Kobaz> i have an array i want to itterate through
<Kobaz> .each is giving me strange results
<Kobaz> apparently you can do $.each(collection, fn)
<Kobaz> so i give it my array as the collection, and the callback gets "0", <Kobaz> even though my collection has stuff in it
<ShockWRK> Kobaz, for an array, it expects a callback with params function(index,value) { }
<ShockWRK> Kobaz, for an object, it expects a callback with params function(key,value) { }
<ShockWRK> that's basically it. 
<Kobaz> yeah
<ShockWRK> so 0 is your index, and maybe undefined is the value at index 0 in your array or something. if that sounds wrong, show me your code
<Kobaz> hmm
<Kobaz> so it can only iterate over numeric indecies?
<ShockWRK> no
<ShockWRK> as i said, for an object it expects key,value
<ShockWRK> key == string
<Kobaz> oh
<Kobaz> hmm
<ShockWRK> but, yeah, in javascript arrays always have numeric indeces
<ShockWRK> indices*
<Kobaz>   $.each(window.pageDataVars, function(key, value) {
<Kobaz>     
<Kobaz>   });
<Kobaz> nothing fancy
<Kobaz> and pageDataVars has one item in it
<Kobaz> which isn't 0... it's a named item
<ShockWRK> window.pageDataVars is undefined
<Kobaz> it is defined
<ShockWRK> in the code you're showing me, it's not.
<Kobaz> well yeah but i define it
<ShockWRK> yeah, well, no shit. all i'm saying is that you're not giving me enough to work with
<Kobaz> well pageDataVars has one item, which is an array in it
<Kobaz> er, the item is an array itself
<ShockWRK> window.pageDataVars is undefined
<Kobaz> ShockWRK: it is
<ShockWRK> Kobaz, helping you is one of the most frustrating endeavours i've attempted today
<Kobaz> hah why
<Kobaz> what info do you want
<booch> ShockWRK: that's what I currently have. just wondering if there is a more intuitive option
<ShockWRK> Kobaz, because i fucking told you why. give me your code so i can run it. right now you're giving me code that won't fucking run.