title: Is it possible to create a method in a class that references another class in javascript?
body: <p>Apologies if this is a newbie question but I'm learning how to use classes in JavaScript and am running into something I'm not sure is possible.  Maybe my syntax is incorrect or there's a better way to go about this.</p>
  <p>I have 2 files, each contain a class to construct an object which I'm calling in a third file (my questions are below this sample JS):</p>
  <p><strong>file1</strong></p>
  <pre><code>import { Second } from &quot;./file2&quot;;
          
  class First {
   constructor(
     parameter1,
     parameter2
   ) {
     this.parameter1 = parameter1;
     this.parameter2 = parameter2;
     }
    method1() {
     this.parameter1 = this.parameter1 + &quot; &quot; + Second.parameterA
     return this.parameter1;
     }
   }
  
   export { First };
  </code></pre>
  <p><strong>file2</strong></p>
  <pre><code>class Second {
    constructor(
      parameterA,
      parameterB
    ) {
      this.parameterA = parameterA;
      this.parameterB = parameterB;
    }
  }
  
  export { Second };
  </code></pre>
  <p><strong>file3</strong></p>
  <pre><code>import { First } from &quot;./file1&quot;;
  import { Second } from &quot;./file2&quot;;
      
  const first = new First(
    &quot;someStringForParameter1&quot;,
    &quot;someStringForParameter2&quot;
  );
      
  const second = new Second(
    &quot;someStringForParameterA&quot;,
    &quot;someStringForParameterB&quot;
  );
  
  console.log(first.method1());
  </code></pre>
  <p>The issue is when I call method1() in the third file I get parameter1 but parameterA is undefined in the console.  I'm not sure why this is the case.  Is this a legal use of imported classes within another class?</p>
  <p>I've tried importing the files in different orders (not surprised that didn't work) and moving the the Second class into the same file as the First class.  I'm able to console.log() all parameters of the First and Second class from the third file successfully but the method I'm calling only returns &quot;someStringForParameter1 undefined&quot;.  My goal is for console to state &quot;someStringForParameter1 someStringForParameterA&quot;.  There are no errors in console and the linter (ESLint) I'm using in VS Code isn't highlighting anything.  Any help on this would be much appreciated!</p>