Bad juju with for/in loop
<p>I have a small script that looks like this:</p>

<pre><code>hideElements = arguments.shift().split ( ',' );
for ( iterator in hideElements ) { 
    console.log ('  --&gt; hiding ' + hideElements[iterator] );
    lg_transitions ( {kind:"slide-up"} , { target : hideElements[iterator] } );
}
</code></pre>

<p>When I run it in the debugger all things start quite rationally. I put a breakpoint at the first line listed above. After pressing the "step over next function call" button to initialise the "hideElements" variable to the following:</p>

<p><img src="http://i.stack.imgur.com/r0Y35.png" alt="enter image description here"></p>

<p>This is what is what I would have expected but then after completing the first (and should be the only) iteration it comes back to the head of the loop and the "iterator" which had started at 0 has now strangely changed to "remove". Huh? No idea where that came from. But in the console.log message that follows there might be a hint ... it prints the following to the console:</p>

<p><img src="http://i.stack.imgur.com/r6yEH.png" alt="enter image description here"></p>

<p>This is a function called -- you guessed it -- "remove". It is a function that I added recently for a different reason but it is not called directly or indirectly and so I'm at a loss as to why this would be picked up here. For anyone interested in the full code for "remove", here it is:</p>

<pre><code>// Array Remove - By John Resig (MIT Licensed)
Array.prototype.remove = function(from, to) {
   var rest = this.slice((to || from) + 1 || this.length);
   this.length = from &lt; 0 ? this.length + from : from;
   return this.push.apply(this, rest);
}
</code></pre>

<p>ADDITION:</p>

<p>The code I had neglected to add earlier was the initialisation of the arguments array. Here's what I had (note I've since changed the name to "args" instead of arguments):</p>

<pre><code>function ConditionalFormatting ( key , eventObject , setOfRules ) {
console.log ("Entering conditional formatting: key is " + key + ", eventObject is " + eventObject.attr('id') + ", setOfRules is " + setOfRules );
var ruleStrings = [];
ruleStrings = setOfRules.split (';');
var targetOverride = false;
jQuery.each ( ruleStrings , function ( i , ruleString ) {
    // There is a rule, now let's find out which one
    var targetElement;
    var args = [];
    args = ruleString.split('::');
    var rule = args.shift();
</code></pre>
