Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array_diff
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/123.0.0.0 Safari/537.36
Browser:
Chrome 123
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Best
149050448.0 Ops/sec
Mine
146135952.0 Ops/sec
Script Preparation code:
var a = [1,2,2,2,3,4,5,6,8,4,5,8,4,6,3,5]; var b = [2,4];
Tests:
Best
function array_diff(a, b) { return a.filter(function(x) { return b.indexOf(x) == -1; }); }
Mine
function array_diff(a, b) { let arrStr = a.join(''); b.forEach(function(item) { arrStr = arrStr.replace(new RegExp(item, 'g'), ''); }); return arrStr.split('').map(function(t){return parseInt(t)}); }