v1
- by lamik 1/27/202100
disable setup HTML
Setup HTML
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
disable setup JavaScript
Setup JavaScript
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";
delete caserun single casemove downdrag and drop case


ready



function A(arr, name) {
  let idx = arr.findIndex(o => o.name==name);
  if(idx>=0) arr.splice(idx, 1);
  return arr;
}

A([...a],n);
delete caserun single casemove upmove downdrag and drop case


ready



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);
delete caserun single casemove upmove downdrag and drop case


ready



function C(arr, name) {
  let idx = arr.findIndex(o => o.name==name);
  delete arr[idx];
  return arr;
}

C([...a],n);
delete caserun single casemove upmove downdrag and drop case


ready



function D(arr, name) {
  return arr.filter(el => el.name != name);
}

D([...a],n);
delete caserun single casemove upmove downdrag and drop case


ready



function E(arr, name) {
  let result = [];
  arr.forEach(o => o.name==name || result.push(o));
  return result;
}

E([...a],n);
delete caserun single casemove upmove downdrag and drop case


ready



function F(arr, name) {
  return _.reject(arr, el => el.name == name);
}

F([...a],n);
delete caserun single casemove upmove downdrag and drop case


ready



function G(arr, name) {
  let o = arr.find(o => o.name==name);
  return _.without(arr,o);
}

G([...a],n);
delete caserun single casemove upmove downdrag and drop case


ready



function H(arr, name) {
  $.each(arr, function(i){
      if(arr[i].name === 'Kristian') {
          arr.splice(i,1);
          return false;
      }
  });
  return arr;
}

H([...a],n);
delete caserun single casemove updrag and drop case


ready



function I(arr, name) {
  return $.grep(arr,o => o.name!=name);
}

I([...a],n);
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN