testarrayloop

JavaScript performance comparison

Test case created by phyking

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  let str='a'.repeat(100000)
      let arr=str.split('')
   

};
</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
for of
for(let value of arr){
value = value +"1"
    }
pending…
for in
for(let key in arr){
arr[key] = arr[key] +"1"
    }
pending…
for
for(let i=0;i<arr.length;i++){
 arr[i] = arr[i] +"1"
    }
pending…
foreach
arr.forEach(function(value,index,list){
value = value +"1"
})
pending…
map
let newarr=arr.map((value,index,list)=>{
value = value +"1"
})
pending…
foreach=>
arr.forEach(item=>item = item+"1")
pending…
for len
for(let i= 0,len=arr.length;i<len;i++){
arr[i] = arr[i] +"1"
    }
pending…

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

0 Comments