在javascript / node.js中有没有相当于python的inspect.getargspec?

时间:2017-01-10 11:58:59

标签: javascript python node.js inspect

我想获得Function的参数名称列表,例如:

var f = (a, b, c) => console.log(a, b, c);
var [fargs] = something.like.inspect.getargspec(f);
console.log(fargs); // ['a', 'b', 'c']

1 个答案:

答案 0 :(得分:1)

如果您正在使用Node并想要参数名称,请查看introspect NPM模块:

> var introspect = require('introspect')
> var f = (a, b, c) => console.log(a, b, c);
> console.log(introspect(f))
[ 'a', 'b', 'c' ]