title: How to access global variable in function hook in javascript?
body: <p>I want to use global variable 'x' in the below hook funcion.</p>
  
  <pre><code>var x = 10; //global variable
  
  var oldA = a;    
  
  a = function a(param){
  
      alert(x);        //showing error: x is undefined 
  
      return oldA(param);
  
  }
  </code></pre>
  
  <p>How to resolve the error? </p>