How to use private JS class variables

1 · · Sept. 30, 2019, 4 a.m.
Private class variables in JavaScript Private variables in JavaScript is gaining browser support. As I right this, it’s supported in ~63% of browsers. You can use the Babel plugin @babel/plugin-proposal-class-properties to transform it into cross-browser code, though. Let’s take a look at how you can use private variables in ES6 classes. Private fields - basics You can declare private fields in ES6 classes by prefixing the variable name with a #, like so:...