Christian Heilmann’s blog post Abandonware of the web: do you know that there is an HTML tables API? taught me about that there’s a better way to build <table>s in vanilla Javascript than manually creating all the elements. HTMLTableElement has attributes like .rows that contains all rows (rather than doing the following as I have done until now:)

const table = document.querySelector('table')
 
// How I've done it so far
const rows = table.querySelectorAll('tr')
 
// Better way through this API
const rows = table.rows;

It also provides a way to insert and delete elements like tbody, thead and tr through table.insertTBody(), table.insertTHead() and table.insertRow() respectively.

I don’t understand how I didn’t know this. It’s been there pretty much since the beginning of modern browsers (and probably even before that) but it took me 20 years of writing HTML to run into it.