| The # sigil has always bummed me out too. Supposedly it's because of this: > Why isn't access this.x? > Having a private field named x must not prevent there from being a public field named x, so accessing a private field can't just be a normal lookup. https://github.com/tc39/proposal-class-fields/blob/main/PRIV... Combined with this: > Why aren't declarations private x? > This sort of declaration is what other languages use (notably Java), and implies that access would be done with this.x. Assuming that isn't the case (see above), in JavaScript this would silently create or access a public field, rather than throwing an error. This is a major potential source of bugs or invisibly making public fields which were intended to be private. https://github.com/tc39/proposal-class-fields/blob/main/PRIV... But I still think it's weird. |
Same goes for methods that you have to manually bind to `this` in the constructor etc.
It literally is one of the "they didn't think if they should" parts of the language.