Deleting a column from a multidimensional array in javascript

前端 未结 6 1303
遥遥无期
遥遥无期 2020-12-06 00:20

I have a 2D array:

var array = [[\"a\", \"b\", \"c\"],[\"a\", \"b\", \"c\"],[\"a\", \"b\", \"c\"]]

I want to delete an entire column of thi

6条回答
  •  佛祖请我去吃肉
    2020-12-06 00:51

    This function doesn't use splice and it removes any column you want:

    function removeEl(array, remIdx) {
     return array.map(function(arr) {
             return arr.filter(function(el,idx){return idx !== remIdx});  
            });
    };
    

    Hope this is what you are looking for

提交回复
热议问题