title: How to access a parent's class's static variable in JS?
body: <p>I have a main static class which starts to become lengthy and hard to read for my comfort. I want to move some of its components (nested static classes) into other files to clean things up.</p>
  <p>My problem comes when I move the <strong>User</strong> subclass into a separate file, even when I import the main class into that new file, the <strong>guildServer</strong> static variable from the main class is undefined, despite always being set previously using the <strong>init</strong> I've previously made.</p>
  <p>Here's my code:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// corvus.js (main static class)
  
  module.exports = class Corvus{
    // ...
    static guildServer = null;
  
    static init(callback){
      // Sets guildServer (which is Guild object from Discord.js), is called when starting the program and is always executed before anything else.
    }
  
    static User = require("path to user.js");
  
    // ...
    // Other classes I want to move into separate files as well
  }</code></pre>
  </div>
  </div>
  </p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// user.js
  
  // Import corvus.js else its parameters are unknown
  const Corvus = require('path to corvus.js');
  
  module.exports = class User{
      /**
       * Returns whether a user is a guild member or not.
       * @param {User} userID
       * @returns {Boolean}
       */
      static isMember(user){
          let member = Corvus.guildServer.member(user);
          if(member){
              // Do something
          }
          return false;
      }
      
      // ...
  }</code></pre>
  </div>
  </div>
  </p>
  <p>When I call Corvus.User.isMember('userID'), I get the error &quot;Cannot read property 'member' of undefined&quot; from the isMember() function, which means Corvus.guildmember is undefined when used in user.js.
  However, I didn't have this error when the User class was directly nested in the Corvus class.</p>