The HTMLTableElement.caption property represents the table caption. If no caption element is associated with the table, this property is null.
HTMLTableElement.caption
null
A string.
if (table.caption) { // Do something with the caption }
HTMLTableElement