title: Calling cross-script arrays
body: <p>I'm calling two scripts.
  The first...</p>
  
  <pre><code>&lt;script language="Javascript" type="text/javascript" src="scripts\arrayBuilder.js"&gt;&lt;script&gt;
  </code></pre>
  
  <p>which contains the following code:</p>
  
  <pre><code>function myObject(var1, var2) {
      this.foo = var1;
      this.bar = var2;
  }
  
  var myArray = []
  
  myArray[0] = new myObject('foo', 'bar');
  myArray[1] = new myObject('bar', 'foo');
  </code></pre>
  
  <p>And the second </p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript" src="scripts\arrayOutput.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Contains this code (I'm creating and appending table elements):</p>
  
  <pre><code>var td = tr.appendChild(document.createElement('td'));
  var tdText = "myArray[0] = " + myArray[0];
  td.innerHTML = tdText ;
  </code></pre>
  
  <p>But the cell text (and console text, when I output it to the console in FireFox) says:</p>
  
  <pre><code>"myArray[0] = [object Object]"
  </code></pre>
  
  <p>So, on the other questions which were answered here (and in other web sites), this should work, because variables (including arrays) are "global" to the window that the page is displayed in...except that it's not, and I haven't been able to find out WHY it's not.  I could just combine the two scripts, but I figured it would be best to separate them because their roles are different: one builds and populates arrays, the other does some other stuff on the page and then (should) use the data that was added to the arrays in the first script.</p>
  
  <p>Am I going about this wrong, or am I missing something very simple here?  Thanks in advance, everyone.</p>