title: Can't access window["var_name"] with Webpack Encore
body: <p>Based on the code below, I have a varaible <code>mdcDialog</code>, which is initialized with <code>material-components-web</code> (MDCDialog) library once page is loaded.</p>
  
  <p>On form submit, default event is prevented and instead, <code>ajaxSubmit()</code> handle the form.<br>
  The response is a json object, from which I can find the variable <code>response.modal.modal</code> with it's string value <code>mdcDialog</code>.</p>
  
  <p>But for one reason or another, <code>console.info(window[response.modal.modal]);</code> return undefined instead of the variable <code>mdcDialog</code>.<br>
  On the other hand, doing <code>console.log(mdcDialog)</code> output the variable as it should.</p>
  
  <p>How can I access my variable <code>mdcDialog</code> from a string response if <code>window</code> isn't working?</p>
  
  <p><kbd><strong>app.js</strong></kbd></p>
  
  <pre><code>/* --- VARS --- */
  const page="#page";
  let mdcDialog;
  
  /* --- FUNCTIONS --- */
  function ajaxSubmit(node) {
      $.ajax({
          type: node.attr("method"),
          url: node.attr("action"),
          enctype: "multipart/form-data",
          data: new FormData(node[0]),
          processData: false,
          contentType: false,
          cache: false
      }).done(function(response, status, xhr) {
          if(response !== false) {
              /** @var response.modal */
              if(typeof response.modal !== "undefined") {
                  /** @var response.modal.action */
                  /** @var response.modal.modal */
                  /** @var response.modal.content */
                  if(response.modal.action === "load") {
                      console.info(window[response.modal.modal]);
                  }
              }
          }
  
      }).fail(function(request, status, error) {
          console.error(request);
          console.error(status);
          console.error(error);
      });
  }
  
  /* --- ACTIONS --- */
  $(document).ready(function() {
      mdcDialog=new mdc.dialog.MDCDialog(document.querySelector("#dialog-level.mdc-dialog"));
  
      $(page).on("submit", ".ajs", function(e) {
          e.preventDefault();
          ajaxSubmit($(this));
      })
  });
  </code></pre>