というオブジェクトがあります。Button_Objs
その目的は、すべてのButton
オブジェクトを保持することです。Button_Objs
各変数を反復処理する関数を my に作成しました。ここに問題があります。次のif statement
ように書かれていますif (i typeof Button){}
。これを行うButton
と、保存されているオブジェクトのみが選択されます。
これは、この JSFiddle です: http://jsfiddle.net/MichaelMitchell/vcZTR/15/
var Button_Objs = function() {
this.getButtons = function() {
var i;
for (i in this) {
if (type of i == Button) { //PROBLEM, also does not work with instanceof.
document.getElementById('console').innerHTML += ( "button: " + i + "<br />");
}
}
};
};
私も試しinstanceof
ましたが、残念ながらうまくいきません:(