I want to use inheritance concept in js, so what i did is
function myGarage(x) {
var _x = x;
Object.defineProperty(this, "BenZ", {
get: function () {
return _x;
},
set: function (value) {
_x = value;
},
enumerable: true,
configurable: true
});
}
myGarage.prototype = new MyCar();
function MyCar() {
var _x =0;
Object.defineProperty(this, "Audi", {
get: function () {
return _x;
},
set: function (value) {
_x = value;
},
enumerable: true,
configurable: true
});
}
After this i created there instance for myGarage.
var g1 = new myGarage(true);
var g2 = new myGarage(false);
var g3 = new myGarage("null");
The problem here is when i set g1.Audi = 10; all other instance of myGarage's Audi will hold the sample value
(eg)
g1.Audi = 10;
var a = g2.Audi // a is 10
var b = g3.Audi; // b is 10
but i set the value to g1.
what i need is other instance must hold the default value or undefined