JavaScriptオブジェクトのすべての属性と関数を取得する方法
573 ワード
これはちょっとJavaの反射に似ていて、ほほ~~~
添付ファイルに出力された結果...
function MyObject(){
this.color = 'red';
this.flavor = 'strawberry';
this.azimuth = '45 degree';
this.favoriteDog = 'collie';
this.sayHello = function(){alert('Hello..........!');
}
}
var myObj = new MyObject();
var debug = "discovering...
";
for(var i in myObj)
debug += i + " -> "+myObj[i]+"
";
alert(debug);
添付ファイルに出力された結果...