How to remove row in two dimensional array in JavaScript with row number. If I want to delete all elements in row number 4 then how can do it??
Just call the splice(4, 1)
method, when 4 is row number and 1 is number of rows to remove -
twoDimensionalArray.splice(4, 1); // remove 4th row
Also shift()
and pop()
are very handy methods which remove first and last rows accordingly -
twoDimensionalArray.shift(); // to remove first row
twoDimensionalArray.pop(); // to remove last row