Javascript class - class instance variables declaration

In Java I could:

  class Stuff{
    //a instance var not got trough constructor
    color c = color(0,0,0);

     Stuff(float _x){
      float x = _x;
    }
  }

in js, instance vars need all to be inside the constructor right? Like this?

class Stuff(){
  // only methods, right?
  constructor(x){
    this.x = x
    //a instance var not got trough constructor
    thisc = color(0,0,0);

  }
}

Did I get this correct?

2 Likes

Ok, thanks for pointing me the specific part of the docs. Didn’t find this. I see I got this wrong. Will study. Instance public fields… very well, knowing the name is a lot :)))
cheers

2 Likes