How to check if variable is an initialized DataTable?
<p><strong>Is there a way to determine if a variable is an initialized DataTable or not?</strong> I assumed <a href="https://datatables.net/reference/api/$.fn.dataTable.isDataTable()" rel="nofollow"><code>$.fn.dataTable.isDataTable()</code></a> could be used, but this only works for table selectors, not for variables containing an initialized DataTable. This function is returning false for such variables:</p>

<pre><code>var table = $("#table").DataTable(); // Valid initialized DataTable
console.log($.fn.dataTable.isDataTable("#table")); // Returns true
console.log($.fn.dataTable.isDataTable(table)); // Returns false...why?
</code></pre>

<p>Since <code>$.fn.dataTable.isDataTable()</code> cannot be used to check a <em>variable</em>, is there another way to see if such a variable is an initialized DataTable? I'm basically trying to do this:</p>

<pre><code>if (isDataTable(variable)) {
    // datatable ... do datatable stuff
} else {
    // not a datatable... do other stuff
}
</code></pre>