title: Javascript ES6 class definition not accessible in window global
body: <p>I have come across an interesting issue, at least I think it's interesting, and a little annoying. I have a class, for this question I will keep it extremely simple...</p>
  
  <pre><code>class Foo {
      static pageChange() {
          console.log('The page changed');
      }
  }
  </code></pre>
  
  <p>Now, I can access that with Foo.pageChange() no problem, everything works as expected. The hard part, and interesting bit comes in when I try to access this dynamically.
  I have a separate object that monitors events and handles dispatching them as needed. This pertains to the Google visualization library, where I have a table, and the table has events tied to it. I have an object that is responsible for creating all of this from PHP output. It is one heck of a system, in an easy explanation you can do something like this in PHP...</p>
  
  <pre><code>GoogleVisLibrary::renderChart(
      array(
          'chartType' =&gt; 'table',
          'chartData' =&gt; $this-&gt;chartData,
          'chartOptions' =&gt; $this-chartOptions,
          'events' =&gt; array(
               'sort' =&gt; 'Foo.pageChange'
          )
  );
  </code></pre>
  
  <p>now that will create teh table and all that good stuff. The problem is accessing that static method in the Foo class in javascript. What I had prior to creating the Foo as a class was this.</p>
  
  <pre><code>var Foo = {
      pageChange: function() {
           console.log('page changed');
      }
  }
  </code></pre>
  
  <p>then in my event library handler thingy it would look something like this..</p>
  
  <pre><code>for(var i = 0, l = events.length; i &lt; l; i++) {
      window[events.className][events.fnName].apply();
  }
  </code></pre>
  
  <p>and that would work fine because Foo can be accessed through window['Foo']
  but when you use the class definition shown in the first code snippet, you can no longer access it from the window super global, it just outputs 'undefined'.</p>
  
  <p>So, is there any way to access a static method in a class, through a dynamic reference like you can with the Foo object through the window global?</p>
  
  <p>I am hoping that makes sense and I am explaining it correctly. If anyhting doesn't make sense please feel free to ask, I will try to explain better. Thank you in advance for any help you can give.</p>