How to check in JavaScript if table row with specific index exist?

Mic*_*ael 1 javascript

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?

Mat*_*and 5

Since undefined is falsey, you can just do this:

if (trows[j]) {
    trows[j].style.display = 'table-row';
}
Run Code Online (Sandbox Code Playgroud)