Passing data in JavaScript
<p>Having a problem understanding what I will call a variable scope question for lack of a better description.  </p>

<p>Say I have a page with two functions, <code>one()</code> and <code>two()</code>. The first function has a locally-scoped variable <code>x</code> with an object in it. This function builds an element, below, in the DOM and this element contains an <code>onClick</code>, which calls the second function, and needs to pass <code>x</code> to the second function as an argument. I.e. the second function needs access to the data that is scoped to the first function.</p>

<p>I have tried:</p>

<pre><code>&lt;something onClick="two(x);"&gt;
</code></pre>

<p>but this doesn't seem to work.  I know that there is a way to make <code>x</code> global but I have found in my other languages that globally-scoped variables are discouraged as being dangerous.</p>
