a little `private` quirk

# Herby Vojčík (14 years ago)

let's assume a constructor than calls this.reset(...) method in the process of initialization of an instance; and that, this method sets up lot of object properties to set up initial state, including private ones using private(this).foo = "bar"; kind of statements.

It seems to me there is a little quirk, but maybe it is a feature:

  • when there is at least one private x = ...; statement in the constructor itself before the call to this.reset(...), everything works perfectly, even undeclared private fields are set up fine;
  • when there is not such a statement, this.reset(...) fails? There is no private variable record present.

That is, my question is, does private(this).foo = "bar"; create a private variable record if it is not present?