How to get function parameter names/values dynamically?

前端 未结 30 2596
说谎
说谎 2020-11-22 00:13

Is there a way to get the function parameter names of a function dynamically?

Let’s say my function looks like this:

function doSomething(param1, par         


        
30条回答
  •  醉话见心
    2020-11-22 00:26

    This package uses recast in order to create an AST and then the parameter names are gathered from their, this allows it to support pattern matching, default arguments, arrow functions and other ES6 features.

    https://www.npmjs.com/package/es-arguments

提交回复
热议问题