jquery iterator function parameters
<p>How can I pass a parameter to a jquery iterator function (or whatever they're called), like:</p>

<pre><code>    var states = new Array();
    states.push(true);

    $(children).each(function(states) {
        if(this.depth&gt;states.length)
        {
            states.push(this.collapsed);
        }
        else if (this.depth&lt;states.length)
        {
            states.pop();
        }

        var collapsed=states[states.length-1];
    }
    );
</code></pre>

<p>The "states" parameter arrives either as an int or a boolean, never an array. Suggestions? I'd prefer not to declare states as global. (The code above resides inside of a method).</p>
