Is there anyway to create private fields in ecma6 class that will not be inherited in child-class?
EDIT:
Here is example that almost solved problem: http://jsfiddle.net/z911nrt4/2/
(function() {
'use strict';
class CSampleClass {
constructor(value1, value2) {
if ( this.constructor.name == "CSampleClass" ) {
this.privateVar = "is here"; //this wont be inherited
}
this.v1 = value1;
this.v2 = value2;
}
}
class CSampleClassChild extends CSampleClass {
constructor(value1, value2) {
super(value1, value2);
}
}
var test = new CSampleClass(1,2);
var test2 = new CSampleClassChild(1,2);
console.log("privateVar from object(CSampleClass):", test.privateVar);
console.log("privateVar from object(CSampleClassChild):", test2.privateVar);
})();
Variable is not-inheritable, but in ugly way and of course it is still public-access field.