Why does the array still have a non-zero length after deletion?

前端 未结 5 1951
后悔当初
后悔当初 2021-01-14 12:14

I have the following code that outputs the length of an array, deletes it, and then outputs the new length:

console.log($scope.adviceList.activeAdvices.lengt         


        
5条回答
  •  北海茫月
    2021-01-14 12:57

    I created a new array and pushed elements on it to get the right length. For example, I had this for table headers:

     var finalTableHeaderArray = [];
    
     tableHeaderArray.forEach(function (element, index, array) {
        if (removeDisplayItems.indexOf(index) === -1)
            finalTableHeaderArray.push(element);
     }, self);
    

    Not exactly your question, but it could help others.

提交回复
热议问题