The json array deletes an object, and the length of the data returned is still the original length.

A json array that deletes the specified object through splice, and the final returned array length is the original length, but the original data is replaced by []. The
code is as follows:
table.on ("tool (sampleList)", function (obj) {

)
            var data = obj.data;
            if (obj.event === "del") {
                layer.confirm("" + "<span style="color:red;">" + data.name + "</span>" + "", function (index) {
                    obj.del();
                    for(var i=0;i<infoList.length;iPP){
                        if(infoList[i].name==data.name){
                            infoList.splice(i,1);
                        }

                    }
                    $("-sharpinstrumentPurchaseInfoList").val(JSON.stringify(infoList));
                    layer.close(index);
                });
            }
        })
        
        :
        

clipboard.png
:
[{"page":1,"limit":10,"displayStart":0,"flag":0,"userId":null,"userType":0,"id":14,"purchaseId":5,"name":"111","specification":"","unit":"","price":null,"num":null,"generatingUnit":"","LAY_TABLE_INDEX":0},{"page":1,"limit":10,"displayStart":0,"flag":0,"userId":null,"userType":0,"id":15,"purchaseId":5,"name":"sjh","specification":"","unit":"","price":null,"num":null,"generatingUnit":"","LAY_TABLE_INDEX":1},{"page":1,"limit":10,"displayStart":0,"flag":0,"userId":null,"userType":0,"id":16,"purchaseId":5,"name":"222","specification":"","unit":"","price":null,"num":null,"generatingUnit":"","LAY_TABLE_INDEX":2},{"page":1,"limit":10,"displayStart":0,"flag":0,"userId":null,"userType":0,"id":17,"purchaseId":5,"name":"333","specification":"","unit":"","price":null,"num":null,"generatingUnit":"","LAY_TABLE_INDEX":3}]
:

clipboard.png
data are as follows:
{[], []}

Apr.27,2022

I tried it with your code, but there was no problem. By the way, I wrote a

myself.
var newArr = infoList.filter(function(item) {
        return item.name != "111";
    });

there is something wrong with your code, for loop, and then you delete splice, the length of the array will change, but I will still increase normally
if you want to delete the array with for, you should delete it from back to front


<script>
//     



/*
  :     
  :   
*/

const a = {name: 'wss', age: '16',sex: 'man'}


// 
// let b = a

// console.log(a,'') // {name: 'wss', age: '16',sex: 'man'}
// console.log(b, '') // {name: 'wss', age: '16',sex: 'man'}
// console.log('') // 
// b.age = '17'
// console.log(a, '') // {name: 'wss', age: '17',sex: 'man'}
// console.log(b, '') // {name: 'wss', age: '17',sex: 'man'}


// 3     
  // let {...c} = a  //  
  // let c = Object.assign({}, a) // 

  var clone = function (obj) { // 
      return JSON.parse(JSON.stringify(obj));
  }

  let c = clone(a)

  console.log(a,'') // {name: 'wss', age: '16',sex: 'man'}
  console.log(c, '') // {name: 'wss', age: '16',sex: 'man'}
  console.log('') // 
  c.age = '17'
  console.log(a, '') // {name: 'wss', age: '16',sex: 'man'}
  console.log(c, '') // {name: 'wss', age: '17',sex: 'man'}
</script>
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b40143-2c4ef.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b40143-2c4ef.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?