Optimal way of skipping certain values in a for loop What would be the fastest way of skipping certain values in a for loop? This is what I intend to do in its most basic form, with about 20 more keys to omit.

for (var key in arr ) {
    if ( key != 'ContentType' &amp;&amp; key != 'FileRef' ) {
        arrayPushUnknown( columns, formatTitle( key ), true, key )
    }   
}
Tests across various browser has shown a reverse while loop is fastest.
Accessing array.length is slower than storing it in a variable to iterate on.
You can just "push" to an array by storing the value in the last element which is conveniently at .length
A switch may not be much faster in this case (though it can be with other data) than a bunch of &amp;&amp;s and ||s, but its much easier to read and the fallthrough characteristic allows you to write like code in groupings.  In this case we only have 2 groups: do nothing (break;) and the default "push"


For example:

var i=arr.length;
var newarr=[];
while (i--){
  switch (arr[i].key){
    case 'ContentType' :
    case 'FileRef' :
    case (other) :
    case (cases) :
    case (here) :
    break;
    default: newarr[newarr.length]=arr[i];
  }
}


On a few newer browsers (Chrome for one), push is faster than direct assignment.  Note that this will be reversed from the original array, but if you need to keep them in the same order using for(var i=0,len=arr.length;i&lt;len;i++), I caution you not to be tempted to use newarr[i]=arr[i] or you will get empty slots where your keys match your blacklist.