I want private variables to be constructed for each child and not shared. (That’s the minimum I need…)
function AbstractClass(){
var private_var; // not shared
// todo : how to create a static(shared) variable?
this.virtual_method = function(){};
this.some_fun = function(){
console.log(private_var);
}
// todo : how to access static(shared) variable?
}
this base abstract class should be convenient enough for constructing many children out of it
function Child1(param){
private_var = param;
this.virtual_method = function(){alert('child1');}; //redefining
this.some_fun();
}
var first_child = new Child1(5); //console : 5
var second_child = new Child1(16); //console : 16
first_child.some_fun() //console : 5;
second_child.some_fun() //console : 16;
fist_child.virtual_method(); // alert
Please help me… I need some working code to be a guide for me
If you mean the library prototype.js, look here. (I’m guessing you do, because native javascript does not have classes).