I tried to achieve the prototypical inheritance, in when there is private variables in parent object.
Consider a code like,
function Piece(isLiveArg) {
var isLive = isLiveArg; // I dont wish to make this field as public. I want it to be private.
this.isLive = function(){ return isLive;}
}
Piece.prototype.isLive = function () { return this.isLive(); }
function Pawn(isLiveArg) {
// Overriding takes place by below assignment, and getPoints got vanished after this assignment.
Pawn.prototype = new Piece(isLiveArg);
}
Pawn.prototype.getPoints = function(){
return 1;
}
var p = new Pawn(true);
console.log("Pawn live status : " + p.isLive());
But, no private variable isLive
exists on parent object, and only public variables exists, then inheritance can able to achieve this very easily.,
Like in this link., http://jsfiddle.net/tCTGD/3/.
So, How would I achieve the same prototypical inheritance, in when there is private variables in parent object.