for vs every

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

<script type="text/javascript"></script>
<script>
Benchmark.prototype.setup = function() {
    var testArray = [];
    for(var x=0;x<10000;x++)
    {
    testArray[x]=x;
    }
    function testFunc(val,index,array)
    {
    var mul = val*val;
    }
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
for
for(var i=0;i<testArray.length;i++)
{
testFunc(testArray[i]);
}
pending…
every
var result = testArray.every(testFunc);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment