<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
let m=500000; // total numer of elements is 2*m = 1000000
let a= [
...Array.from({length:m},(v,k) => ({name:"John"+k, lines:k+",19,26,96"})),
{name:"Kristian", lines:"2,5,10"},
...Array.from({length:m-1},(v,k) => ({name:"John"+(k+m), lines:k+m+",19,26,96"}))
]
let n = "Kristian";
function A(arr, name) {
let idx = arr.findIndex(o => o.name==name);
if(idx>=0) arr.splice(idx, 1);
return arr;
}
A([...a],n);
function B(arr, name) {
let idx = arr.findIndex(o => o.name==name);
return idx<0 ? arr : arr.slice(0,idx).concat(arr.slice(idx+1,arr.length));
}
B([...a],n);
function C(arr, name) {
let idx = arr.findIndex(o => o.name==name);
delete arr[idx];
return arr;
}
C([...a],n);
function D(arr, name) {
return arr.filter(el => el.name != name);
}
D([...a],n);
function E(arr, name) {
let result = [];
arr.forEach(o => o.name==name || result.push(o));
return result;
}
E([...a],n);
function F(arr, name) {
return _.reject(arr, el => el.name == name);
}
F([...a],n);
function G(arr, name) {
let o = arr.find(o => o.name==name);
return _.without(arr,o);
}
G([...a],n);
function H(arr, name) {
$.each(arr, function(i){
if(arr[i].name === 'Kristian') {
arr.splice(i,1);
return false;
}
});
return arr;
}
H([...a],n);
function I(arr, name) {
return $.grep(arr,o => o.name!=name);
}
I([...a],n);