Secure variables in JS object

Im creating the JS object with ES6 technics like thisimage

Im trying to secure the variables in constructor by declaring with ‘let’ and also creating getter and setter. And then I realize that variables in constructor seem can only be declared with ‘this’

Any ideas for securing information :))
Tks anyway !

You’re looking for private variables, which you can do with traditional object constructors but not really well with ES6 classes. Google 'private variablesin es6 classes to read about it.

You can fake it, kind of, using weakMaps and Symbols. Ihave read about them, but haven’t really played with it yet.

1 Like