Javascript Evaluation Questions
<pre><code>var  x  =  5;
function f(y){ return (x+y)-2 }; 
function g(h){ var x = 7; return h(x) }; 
{ var x=10; z=g(f) };
</code></pre>

<p>I'm working through some problems from my textbook in my class to prepare for our next exam, and can't figure out how the above evaluates. </p>

<p>Mostly, I don't understand the call z=g(f), as when f is evaluated, it isn't provided an argument, so how does it evaluate at all? How does it know what y is?</p>

<p>Also, as far as scoping goes, I believe javascript treats most everything as global variables, so the last x that is set would be the x value used in function f, correct?</p>

<p>Thanks for any help!</p>

<p><strong>Please note, these are extra problems in the back of the book I'm practicing to prepare for the exam, these are not direct homework questions.</strong></p>
