class Animal {
sayHello() {}
}
class Fish extends Animal {
const name = "goldfish";
constructor() {
super();
this.hasBrain = true;
}
sayGoodbye() {}
}
let f = new Fish();
想要列出 f 的几个属性怎么做?希望实现这么一个 dir() 函数?
>> dir(f)
["sayHello", "name", "constructor", "sayGoodbye"]
我现在唯一想到的办法是递归遍历 f, f.__prototype__, ...
--
修改:hgoldfish FROM 59.60.25.*
FROM 59.60.25.*