javascript array.splice() does not remove element in the array?

后端 未结 6 1870
轮回少年
轮回少年 2021-01-14 06:51

I have a remove[] array which has all the index positions of all the element with 0 in the data array (as below).

data array:

Retail,1,Utilities,1,Fo         


        
6条回答
  •  轮回少年
    2021-01-14 07:16

    My problem was that splice was removing the wrong element from the array. I saw the answer with the while loop but the solution that I made is :

    var index = jQuery.inArray(element, arr);
    arr.splice(index,1);
    

提交回复
热议问题