Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
JS if + array binary vs object + if
JS indexOf + array vs object + if
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; SAMSUNG SM-J810G) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/16.0 Chrome/92.0.4515.166 Mobile Safari/537.36
Browser:
Chrome Mobile 92
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
indexOf + array
6285.5 Ops/sec
object + if
5969.4 Ops/sec
Script Preparation code:
var arr = []; var obj = {};
Tests:
indexOf + array
arr[0] = 1; arr[1] = 0; arr[2] = 0; arr[3] = 1; if(arr[0]){ console.log('a'); } if(arr[1]){ console.log('b'); } if(arr[2]){ console.log('c'); } if(arr[3]){ console.log('d'); }
object + if
obj.a = true; obj.e = true; obj.f = true; obj.d = true; if(obj.a){ console.log('a'); } if(obj.b){ console.log('b'); } if(obj.c){ console.log('c'); } if(obj.d){ console.log('d'); }