我想获取Function
的参数名称列表,例如:
var f = (a, b, c) => console.log(a, b, c);
var [fargs] = something.like.inspect.getargspec(f);
console.log(fargs); // ['a', 'b', 'c']
最佳答案
如果您使用 Node 并且需要参数名称,请查看 introspect
NPM 模块:
> var introspect = require('introspect')
> var f = (a, b, c) => console.log(a, b, c);
> console.log(introspect(f))
[ 'a', 'b', 'c' ]
关于javascript - javascript/node.js 中是否有与 python 的 inspect.getargspec 等效的东西?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41568327/