I believe it is possible to get 'best of both worlds' using closures inside constructors. There are two variations:
All data members are private
function myFunc() {_x000D_
console.log('Value of x: ' + this.x);_x000D_
this.myPrivateFunc();_x000D_
}_x000D_
_x000D_
function myPrivateFunc() {_x000D_
console.log('Enhanced value of x: ' + (this.x + 1));_x000D_
}_x000D_
_x000D_
class Test {_x000D_
constructor() {_x000D_
_x000D_
let internal = {_x000D_
x : 2,_x000D_
};_x000D_
_x000D_
internal.myPrivateFunc = myPrivateFunc.bind(internal);_x000D_
_x000D_
this.myFunc = myFunc.bind(internal);_x000D_
}_x000D_
};
_x000D_
Some members are private
NOTE: This is admittedly ugly. If you know a better solution, please edit this response.
function myFunc(priv, pub) {_x000D_
pub.y = 3; // The Test object now gets a member 'y' with value 3._x000D_
console.log('Value of x: ' + priv.x);_x000D_
this.myPrivateFunc();_x000D_
}_x000D_
_x000D_
function myPrivateFunc() {_x000D_
pub.z = 5; // The Test object now gets a member 'z' with value 3._x000D_
console.log('Enhanced value of x: ' + (priv.x + 1));_x000D_
}_x000D_
_x000D_
class Test {_x000D_
constructor() {_x000D_
_x000D_
let self = this;_x000D_
_x000D_
let internal = {_x000D_
x : 2,_x000D_
};_x000D_
_x000D_
internal.myPrivateFunc = myPrivateFunc.bind(null, internal, self);_x000D_
_x000D_
this.myFunc = myFunc.bind(null, internal, self);_x000D_
}_x000D_
};
_x000D_