title: Test for jQuery-DataTables API object
body: <p>I'm working with a mix of legacy code that uses the jQuery DataTables plugin (version 1.10.  Some of the old code passes around jQuery object, and some of the old code passes around <a href="https://datatables.net/reference/api/" rel="nofollow noreferrer">DataTables API objects</a>.  I'd like to make all new code accept either a jQuery object or a DataTables API object, but I haven't been able to detect when a variable refers to a DataTables API object.</p>
  
  <p>The only detection method I could find in the API, <a href="https://datatables.net/reference/api/%24.fn.dataTable.isDataTable()" rel="nofollow noreferrer">isDataTable</a>, is not suitable - it take a string selector for a table and returns whether the selection has been turned into a DataTable.</p>
  
  <p>The "class detection" methods in <a href="https://stackoverflow.com/a/1249554/776723">this answer</a> don't work; <code>typeof</code> returns <code>"object"</code>, <code>constructor.name</code> returns <code>"Object"</code>, and I don't know of a constructor to use for <code>instanceof</code> or <code>isPrototypeOf</code>.</p>
  
  <p>As suggested in <a href="https://stackoverflow.com/a/1250766/776723">this answer</a> (to same question), <code>Object.prototype.toString.call(var)</code> returns <code>"[object Object]"</code></p>
  
  <p>In Chrome, <code>console.log(var)</code> produces a summary that looks like it has some other class information:</p>
  
  <pre><code>▶ _Api {context: Array[1], selector: Object, ajax: Object}
  </code></pre>
  
  <p>I imagine that means there is something I could use somewhere but <a href="https://stackoverflow.com/q/27085257/776723">this question</a> about where Chrome gets that name has no useful answers.</p>
  
  <p><strong>How can I detect when a variable refers to a jQuery-DataTables API object?</strong></p>