How to get function parameter names/values dynamically?

前端 未结 30 3134
说谎
说谎 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条回答
  •  猫巷女王i
    2020-11-22 00:35

    Note: if you want to use ES6 parameter destructuring with the top solution add the following line.

    if (result[0] === '{' && result[result.length - 1 === '}']) result = result.slice(1, -1)
    

提交回复
热议问题