i've a nice problem here. I need to understand this
Foo = function(){
};
Foo.prototype = {
buttons: new Array(),
index:'',
add: function(value)
{
this.buttons.push(value);
},
clear:function(){
this.buttons=new Array();
},
count:function(){
return(this.buttons.length);
},
setIndex:function(index){
this.index;
},
getIndex:function(index){
return this.index;
}
};
var A= new Foo();
var B= new Foo();
A.add('toto');
B.add('tata');
A.setIndex(8);
B.setIndex(44);
alert(A.count()+"---"+A.getIndex());
That code gives me : "2---8" !!
So A.count() returns me A.count() + B.count(). Same with B.count() !!
Can anyone explain me this, already had this problem ? How to do ? i simply need the array "buttons" to be unique, proper to each object.