Like Aaron, already mentioned in the comment above, public and private members look the same in Javascript, so there cannot be a method that distinguishes between them. For example, the following TypeScript code
class Car { public model: string; private brand: string; public constructor(model:string , brand: string){ this.model = model; this.brand = brand; } };
compiled for:
var Car = (function () { function Car(model, brand) { this.model = model; this.brand = brand; } return Car; }()); ;
As you can see, in the compiled version of JavaScript there is absolutely no difference between the model and brand members, an event, although one of them is private and the other public.
You can distinguish between private and public elements using some kind of naming convention (for example, public_member and __private_member ).
source share