javascript 列出javascript中的所有内置函数?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8693965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
List all built-in functions in javascript?
提问by Frawr
Is there a way in js to list all the builtin functions and some info on their parameterlists? I couldn't really find anything about reflection to do this sort of thing
js 中有没有办法列出所有内置函数及其参数列表中的一些信息?我真的找不到任何关于反射的东西来做这种事情
edit: The functions such as Math.sin are actually the ones I want to list, actually all built-in functions.
编辑:Math.sin等函数其实就是我要罗列的,其实都是内置函数。
回答by Niet the Dark Absol
Something like this, maybe?
像这样的东西,也许?
for( var x in window) {
if( window[x] instanceof Function) console.log(x);
}
This will list all native functions in the console (excluding one in native objects, such as Math.sin()
).
这将列出控制台中的所有本机函数(不包括本机对象中的一个,例如Math.sin()
)。