javascript反射查找原型方法、全局范围方法和对象
如何找到使用反射定义的原型方法(不是 PrototypeJS)?另外,如何查找全局范围内所有已定义的对象和方法?
How can I find the prototype methods (not PrototypeJS) that have been defined using reflection? Also, how to find all defined objects and methods in the global scope?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
for...in
沿着原型链一路向下,它不保证任何特定的顺序,但它应该循环遍历您正在寻找的所有属性...如果您是寻找仅继承(通过原型)成员,添加
hasOwnProperty()
检查...另外,我从未尝试过这个,但是使用
window< /code>,我相信你会找到你正在寻找的东西 为了...
the
for...in
travels all the way down the prototype chain, it doesn't garauntee any specific order, but it should loop through all the properties you're looking for...If you are looking for only inherited (via prototype) members, add a
hasOwnProperty()
check...also, I've never tried this but, but using
window
, I believe you'd find what you are looking for...要迭代所有原型属性(包括继承的属性):
要查看所有定义的对象,请以相同的方式迭代
window
:To iterate over all prototype properties (including inherited ones):
To see all defined objects, iterate over
window
the same way: