Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
JS indexOf + array vs object + if
JS indexOf + array vs object + if
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Browser:
Chrome 127
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
indexOf + array
5039.2 Ops/sec
object + if
112695.2 Ops/sec
Script Preparation code:
var arr = []; var obj = {};
Tests:
indexOf + array
arr.push('a'); arr.push('e'); arr.push('f'); arr.push('d'); if(arr.indexOf('a') != -1){ console.log('a'); } if(arr.indexOf('b') != -1){ console.log('b'); } if(arr.indexOf('c') != -1){ console.log('c'); } if(arr.indexOf('d') != -1){ 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'); }