title: Do JS variables have a scope if the function that declares them is never called?
body: <p>In this code, how many variables are in the global scope, and how many are in the local scope of the <code>greet</code> function?</p>
  
  <pre><code>var foo = 42;
  var bar = 43;
  
  function greet(name) {
    greeting = 'Hello';
    return greeting + ' ' + name;
  }
  </code></pre>
  
  <p>I believe there are two global variables (<code>foo</code> and <code>bar</code>) and 0 local variables. Since the function never gets called, <code>name</code> and <code>greeting</code> don't get declared so I would say that they are not in the global or local scope.</p>
  
  <p>What do you think? Can <code>greeting</code> and <code>name</code> have a scope if the function <code>greet()</code> is never invoked?</p>