I have a small script that looks like this:
hideElements = arguments.shift().split ( ',' );
for ( iterator in hideElements ) {
console.log (' --> hiding ' + hideElements[iterator] );
lg_transitions ( {kind:"slide-up"} , { target : hideElements[iterator] } );
}
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:

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:

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:
// 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 < 0 ? this.length + from : from;
return this.push.apply(this, rest);
}
ADDITION:
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):
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();
The
argumentsobject is not an actual array. Therefore it doesn’t have theshift()function. If you want the first object in the array, obtain the element at index 0 (first object). Moreover, use a regular for loop to traverse the arguments object.argumentsis not a real array, however, if you wish to use it like it were an array, then useArray.prototype.slice.call( arguments );:From there on you can use hideElements as an array.