Can I use non-static variables when initializing static variables in a JavaScript class?

Can I use non-static variables during initialization of static variables in a JavaScript class?
If it’s possible, then in which cases can I use it?
In my test code, it doesn’t work like I expected:

class Test1 {
  static commonParam = [
    ['Test1', ['Test1', 'Test2', this.param1]]
  ];
  constructor(param1) {
    this.param1=param1;
    console.log(`Test1 param1: ${this.param1}`);
  };
  pintCommonparam(){
     console.log(JSON.stringify(Test1.commonParam));
  }
}

t1 = new Test1(1);
t1.pintCommonparam();

code execution result:

> "Test1 param1: 1"
> "[["Test1",["Test1","Test2",null]]]"

I expected that instead of null the last value of the array would be equal to the value of this.param1

39 thoughts on “Can I use non-static variables when initializing static variables in a JavaScript class?”

  1. 399639 496443Hi. Cool article. Theres a difficulty with the website in chrome, and you might want to check this The browser could be the marketplace chief and a big component of other folks will miss your exceptional writing due to this difficulty. I like your Post and I am recommend it for a Website Award. 821147

    Reply