I have this JavaScript block code:
var trows = table.getElementsByTagName('tbody')[0].rows;
for(var j = ((pageNumber - 1) * rowsPerPage); j < ((pageNumber) * rowsPerPage); j++)
{
trows[j].style.display = 'table-row';
}
Run Code Online (Sandbox Code Playgroud)
Before I implement this row:
trows[j].style.display = 'table-row';
Run Code Online (Sandbox Code Playgroud)
I need to check if table row with scpecific index exists.
How to check in JavaScript if table row with specific index exist?
Since undefined is falsey, you can just do this:
if (trows[j]) {
trows[j].style.display = 'table-row';
}
Run Code Online (Sandbox Code Playgroud)