// 1) обычная инициализация
const table = $elem.DataTable();
// 2) без присвоения
$elem.DataTable(); // =table
Cannot read property 'add' of undefined
Q. I get an error message stating that an API method is not available
A. Very likely you are using a jQuery object rather than a DataTables API instance. The form $().dataTable() will return a jQuery object, while $().DataTable() returns a DataTables API instance. Please see the API documentation for further information.