jquery.grep unexpected behavior
<p>I've run into an interesting discovery using jquery.grep and was wondering if anyone knows why this is happening.  In my code, I am using grep to filter out certain items from an array and then assign the results back to the original array for more filtering.  </p>

<p>E.g. </p>

<pre><code>orderedGroups = jquery.grep(orderedGroups, function{}` ...)
</code></pre>

<p>The desired outcome is that items who's parent id is the id of another item in the array are filtered out -- leaving only the unmatched (parent) items.</p>

<p>What I've discovered is that this actually creates a separate object by the same name.  In other words, doing a <code>console.log(orderedGroups[1])</code>, displays a value not displayed in <code>console.log(orderedGroups)</code></p>

<p>Here is my code:</p>

<pre><code>var a = ['a', '1', '0']; // represents [name, id, parent id]
var b = ['b', '2', '1'];
var c = ['c', '3', '0'];
var d = ['d', '4', '2'];
var e = ['e', '5', '0'];
var f = ['f', '6', '2'];

var groups = [a, b, c, d, e, f];

var orderedGroups = groups;
for (var i = 0; i &lt; groups.length; i++) {
    for (var sg = 0; sg &lt; groups.length; sg++) {
        if (groups[i][1] == groups[sg][2]) {
            orderedGroups = jQuery.grep(orderedGroups, function(value) {
                return value != groups[sg];
            });
        }
    }
}

console.log(orderedGroups)
console.log(orderedGroups[1])​
</code></pre>

<p>Has anyone seen this before, and if so can you explain why this is happening?</p>

<p>Thanks</p>
