title: If anonymous JavaScript functions can access all variables, what about regular functions?
body: <p>In Javascript function variables are local unless they're not declared with "var". That is, unless those functions are anonymous (like the ones used in setInterval and setTimeout. In that case, they have global access to all available variables within the scope that called the anonymous functions.</p>
  
  <p>What about regular functions then? Is there any way to allow them to access all variables too? I ask this due to some cases of having very complicated functions under 1 parent function with many variables, where I suddenly have to turn them from anonymous into regular functions.</p>
  
  <p>For example, let's assume my original anonymous function called alert and now I want to do it through a regular function:</p>
  
  <pre><code>myFunction()
  function myFunction() {
      var a='b' //,b=...,c=...,d=...,e=...,f=...,g=...,h=...,i=...,j=...,k=...
      setInterval(function(){ alert(a) }, 3000) // Works even though a is local
      setInterval(function(){ dummy() }, 3000) // Fails, but would work if I used dummy(a).
      // But then I'd have to use dummy(a,b,c,d,e,f,g,h,i,j,k,...)
  }
  
  function dummy() { // It would have worked had I used dummy(a)
      alert(a)
  }
  </code></pre>