SoFunction
Updated on 2025-02-28

js deletes an instance of an array by specifying subscripts or specifying elements

Examples are as follows:

Delete the specified subscript array element 
=function(index){ 
    if(isNaN(index)||index>=){ 
      return false; 
    } 
    for(var i=0,n=0;i<;i++){ 
      if(this[i]!=this[index]){ 
        this[n++]=this[i]; 
      } 
    } 
    -=1; 
  }; 
Delete the specified element 
 
     = function(val) { 
      for (var i = 0; i < ; i++) { 
        if (this[i] == val) return i; 
      } 
      return -1; 
    }; 
     = function(val) { 
      var index = (val); 
      if (index > -1) { 
        (index, 1); 
      } 
    }; 
    function a(){ 
      var arr = [1, 2, 3, 4, 5]; 
    alert(()); 
    (3); 
    alert(()); 
    } 

The first method of calling

(0);

The above is the entire content of the example of js deleting arrays by specifying subscripts or specifying elements. I hope everyone supports me~