Is it possible to create a method in a class that references another class in javascript?

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.

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):


import { Second } from "./file2";
class First {
 ) {
   this.parameter1 = parameter1;
   this.parameter2 = parameter2;
  method1() {
   this.parameter1 = this.parameter1 + " " + Second.parameterA
   return this.parameter1;

 export { First };


class Second {
  ) {
    this.parameterA = parameterA;
    this.parameterB = parameterB;

export { Second };


import { First } from "./file1";
import { Second } from "./file2";
const first = new First(
const second = new Second(


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?

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 “someStringForParameter1 undefined”. My goal is for console to state “someStringForParameter1 someStringForParameterA”. 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!