DEV Community

Discussion on: JavaScript v TypeScript

Collapse
 
kwiat1990 profile image
Mateusz Kwiatkowski

Regarding new proposal: why to use # instead of private keyword for the private members? Or am I missing something here?

Thread Thread
 
peerreynders profile image
peerreynders

FAQ:

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 below), 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