title: Coffeescript - call function by variable
body: <p>I want to manage part of my layout with coffeescript. I have a left/right panel and I want to be able to switch between them. I have created something like this:</p>
  
  <pre><code>window.switchPanel = (panel = 'left', action = 'toggle') -&gt;
  
    open = (panel) -&gt;
      ...
  
    close = (panel) -&gt;
      ...
  
    toggle = (panel) -&gt;
      ...
  </code></pre>
  
  <p>My question is, how do I structure this so that I can call <code>open/close/toggle</code> by the <code>action</code> variable and can I use something so that I don't have to pass in the <code>panel</code> to every child function? Perhaps <code>@panel</code>?</p>