Test name | Executions per second |
---|---|
Filter | 2218176.5 Ops/sec |
For | 261977.4 Ops/sec |
For 2 | 270132.2 Ops/sec |
For in | 299258.2 Ops/sec |
var arr = [1,2,3,4,null,5,6,"7",8,{a:2},0], farr=[], i,len;
farr= arr.filter(function(item) {
return (item>4);
});
farr = [];
for (i=0,len=arr.length;i<len;i++) {
if (arr[i]<5) continue;
farr.push(arr[i]);
}
farr = [];
for(i=0,len=arr.length;i<len;i++) {
if (arr[i]>4) farr.push(arr[i]);
}
farr = [];
for(i in arr) {
if (arr[i]>4) farr.push(arr[i]);
}