arraySearchTest

JavaScript performance comparison

Revision 2 of this test case created by Francute

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  let trueWasFound = false;
  let arr = [false, false, false, false, false, false, false, false, false, true];

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Loop search with Array.prototype.forEach() with lambda
arr.forEach((element) => {
  if (element === true) {
    trueWasFound = true;
  }
});
pending…
Loop search with Array.prototype.some()
trueWasFound = arr.some(function(element) {
  return (element === true);
});
pending…
Loop search with Array.prototype.forEach()
arr.forEach(function(element) {
  if (element === true) {
    trueWasFound = true;
  }
});
pending…
Loop search with Array.prototype.some() with lambda
trueWasFound = arr.some((element) => (element === true));
pending…

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL.

1 Comment

Francute commented :

First time in this site. But i can't make all 7 code snippets show at the same time...