title: JavaScript accessing variables declared in calling function
body: <p>It's hard to explain my question, so I'm posting some code.</p>
  
  <pre><code>function caller(func) {
      function printMessage(message) {
          console.log(message);
      }
  
      func();
  }
  
  function callee() {
      printMessage('hello world');
  }
  
  caller(callee);
  </code></pre>
  
  <p>I want to access printMessage from callee, but as it currently stands, this throws a ReferenceError. I'd like to avoid declaring printMessage globally, if possible.</p>