Test name | Executions per second |
---|---|
Best | 61282800.0 Ops/sec |
Mine | 65765808.0 Ops/sec |
var a = [1,2,2,2,3,4,5,6,8,4,5,8,4,6,3,5];
var b = [2,4];
function array_diff(a, b) {
return a.filter(function(x) { return b.indexOf(x) == -1; });
}
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)});
}