Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
lodash xor vanila toggle
lodash xor for toggling value vs es6 includes if else
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/121.0.0.0 Safari/537.36
Browser:
Chrome 121
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
lodash xor implemantation
74569.1 Ops/sec
alternative with Sets
682807.0 Ops/sec
Script Preparation code:
var a = Array(256).fill(0).map((_, index) => index) a.push('foo') var b = 'foo'
Tests:
lodash xor implemantation
const res = _.xor(a, [b])
alternative with Sets
function toggleValueInArray(value, list) { if (list.includes(value)) { list.filter(listValue => listValue !== value) } else { return [...list, value] } } const res = toggleValueInArray(b, a)