title: Creating a Table object and appending it later
body: <p>You know how in the normal web DOM, you can create an HTML element, then later add it to the DOM?</p>
  
  <p>I want to do the equivalent of that in Google Apps Script, particularly for Google Docs.  That is, I want to create <code>Table</code> object, let's call it <code>table</code>, without using <code>Body.appendTable()</code>.  Then later I want to append it with <code>Body.appendTable(table)</code>--which <em>does</em> exist in their API already.</p>
  
  <p>The problem is, I don't see any method like <code>createTable()</code> anywhere for this.</p>
  
  <h2>What I've Tried</h2>
  
  <p>Simply using <code>new</code> doesn't work either, apparently:</p>
  
  <pre><code>var table = new Table();
  var table = new Document.Table();
  var table = new GoogleAppsScript.Document.Table();
  </code></pre>
  
  <p>The respective results are:</p>
  
  <pre><code>ReferenceError: "Table" is not defined.
  ReferenceError: "Document" is not defined.
  ReferenceError: "GoogleAppsScript" is not defined.
  </code></pre>
  
  <p>(I tried the last one based on <a href="https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/google-apps-script/google-apps-script.document.d.ts" rel="nofollow noreferrer">https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/google-apps-script/google-apps-script.document.d.ts</a> .)</p>
  
  <p>Or maybe it would work, if I knew the path to the <code>Table</code> interface.  It's not this either, though:</p>
  
  <pre><code>var table = new DocumentApp.Document.Table();
  </code></pre>
  
  <p>...because that yields:</p>
  
  <pre><code>TypeError: Cannot read property "Table" from undefined.
  </code></pre>
  
  <p>(Which makes sense.  <code>DocumentApp</code> doesn't have a <code>Document</code> key.)</p>
  
  <h2>Motivation:</h2>
  
  <p>I know that I could create a temporary doc, then add a temporary table to it, and delete it afterwards.</p>
  
  <p>But that means anywhere the script might die, the user will have to manually clean up this temporary doc themselves.</p>