I have class/viewModel created with Typescript. I made one field in this class as private in order to skip it when I try to get all other class properties.
Is it right and how can I skip my private property?
Object.keys(myObject).forEach(property => {
//some stuff
}
});
Example of my class :
class MyModel{
id: any = ko.observable('');
name: any = ko.observable('');
address: any = ko.observable('');
city: any = ko.observable('');
state: any = ko.observable('');
country: any = ko.observable('');
private secretField= ko.observable('');
}
privatekeyword affects only visibility in TypeScript and doesn't affect JS output.For class properties that weren't defined on the prototype and thus can't be modified with class property decorators, the most straightforward way is to use
_naming convention for private properties: