Comment detail
メソッド名一覧の表示 (Nested Flatten)
上のコードをJavaScriptに移植。IE6とFirefox2で動作確認。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | function A()
{
this.bar = 1;
this.test_bar = 2;
this.baz = [];
this.test_baz = {};
}
A.prototype.foo = function()
{
alert("foo");
}
A.prototype.test_foo = function()
{
alert("test_foo");
}
A.prototype.boo = function()
{
alert("boo");
}
A.prototype.test_boo = function()
{
alert("test_boo");
}
function call_tests(obj)
{
for (var name in obj)
{
var attr = obj[name];
if (attr instanceof Function && name.indexOf("test_") == 0)
{
attr();
}
}
}
call_tests(new A());
|




ocean
#1459()
[
Python
]
Rating0/0=0.00
Rating0/0=0.00-0+
1 reply [ reply ]