title: How to interact with a (variable name unknown) javascript object in a dynamically loaded file
body: <p>Mike Bostock's <a href="https://github.com/mbostock/queue" rel="nofollow noreferrer">queue.js</a> library currently allows me to load a variable number and type of files (css, json, js etc) into a nascent single page browser application:</p>
  
  <pre><code>d3.json("files_to_load.json", function(data) {
  
    var q = queue(1);
  
    data.forEach(function(d, i) {
      q.defer(load_file, d.filename, d.filetype);
    });
  
    q.awaitAll(function(error, results) {
      console.log("results.toSource()=" + results.toSource());
    });
  
  });
  </code></pre>
  
  <p>..where:</p>
  
  <ul>
  <li><code>load_file()</code> simply builds a script specification for appending to the DOM, much the same as the <code>load_image()</code> function shown <a href="https://stackoverflow.com/questions/18081023/queue-js-to-preload-images-is-waiting-forever-callbak/18086989#18086989">here</a>.</li>
  <li><p>the queue.awaitAll() results (here for a successful but extreme case comprising nine files) show an array of seemingly useless <code>(void 0)</code>, ie <code>undefined</code> objects:</p>
  
  <p><code>results.toSource()=[(void 0), (void 0), (void 0), (void 0), (void 0), (void 0), (void 0), (void 0), (void 0)]</code></p></li>
  </ul>
  
  <p>Somewhere amongst these will always one representing the loading of a js file containing a simple closure, the variable name of which is both <strong>unknown</strong> and <strong>differs</strong>, but whose <strong>interface is standard</strong> across all js files:</p>
  
  <pre><code>var closure_with_var_name_unknown = function() {
    var id = "";
    var privateFunction = function() {
        // use id in a way specific to this file
    }
    return {
      callPrivateFunc : function() {
         privateFunction();
      },
      customise : function(what, val) {
         id = val; // in a switch (what) case statement
      }
    }
  }();
  </code></pre>
  
  <p>So, having loaded this js file into the DOM, and assuming customise() is a common to all such js files and closures, I would like to <strong>get a handle on the current closure variable</strong> in order to call customise, as in:</p>
  
  <pre><code>closure_with_var_name_unknown.customise("id", d.id);
  </code></pre>
  
  <p>Would be nice if this were to occur within the q.awaitAll() callback function's success block. :-)</p>
  
  <p>Strategy suggestions? (No jQuery, please).</p>
  
  <p>Thanks!</p>