【问题标题】:Is there any equivalent of python's inspect.getargspec in javascript/node.js?在 javascript/node.js 中是否有任何等效于 python 的 inspect.getargspec?
【发布时间】:2017-05-24 21:54:36
【问题描述】:

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

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

【问题讨论】:

标签: javascript python node.js inspect


【解决方案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' ]

【讨论】:

    猜你喜欢
    • 2020-10-22
    • 2011-05-31
    • 2015-09-08
    • 1970-01-01
    • 2021-01-18
    • 1970-01-01
    • 1970-01-01
    • 2013-05-21
    • 2012-11-05
    相关资源
    最近更新 更多