Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
Chrome 114
Windows
Desktop
one year ago
Test name Executions per second
Delete by Splice 1569919.9 Ops/sec
Delete by Splice Index 1629117.5 Ops/sec
Delete by Filter 1718607.2 Ops/sec
HTML Preparation code:
AخA
 
1
<script>
2
  var array = ["m1c6kzws0iubt8g0zlsug14i","xalskr21dm5ke5wczew154s4i","hvbfe3uq3pmoehpilh4zpvi","ffr2btp9rihf3qce770ttke29","ymwh11qu16qwqn5vaafxhia4i","1l7rj49636ddmk3cbszitchaor","bg1njla9dvdkdlw9mbz1l9pb9","201y3ambt118dt7j7bxc6ry66r","hsgzqv2ex2j9j8znv3uzbyb9","k8tuq5ucdx1whgkdcby44pldi","2sjycnx525scxzfxfmwl7q4cxr"];
3
</script>
Script Preparation code:
x
 
/* these functions assume that only one element matches, so they do not loop! */
function deleteBySplice (array, element) {
  array.splice( array.indexOf( element ), 1 );
}
function deleteBySpliceIdx (array, element) {
  array.splice( element, 1 );
}
function deleteByFilter (array, element) {
  array = array.filter( el => el !== element );
}
Tests:
  • Delete by Splice

     
    deleteBySplice( array, "2sjycnx525scxzfxfmwl7q4cxr" );
    deleteBySplice( array, "m1c6kzws0iubt8g0zlsug14i" );
    deleteBySplice( array, "1l7rj49636ddmk3cbszitchaor" );
  • Delete by Splice Index

     
    deleteBySpliceIdx( array, 10 );
    deleteBySpliceIdx( array, 0 );
    deleteBySpliceIdx( array, 5 );
  • Delete by Filter

     
    deleteByFilter( array, "2sjycnx525scxzfxfmwl7q4cxr" );
    deleteByFilter( array, "m1c6kzws0iubt8g0zlsug14i" );
    deleteByFilter( array, "1l7rj49636ddmk3cbszitchaor" );