私はここでいい問題を抱えています。これを理解する必要があります
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());
そのコードは私に与えます:「2---8」!!
したがって、A.count() は A.count() + B.count() を返します。B.count() と同じ!!
誰かが私にこれを説明できますか、すでにこの問題がありましたか? 実行する方法 ?配列の「ボタン」が一意で、各オブジェクトに適している必要があります。