How to get function parameter names/values dynamically?

前端 未结 30 2594
说谎
说谎 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:27

    I don't know if this solution suits your problem, but it lets you redefine whatever function you want, without having to change code that uses it. Existing calls will use positioned params, while the function implementation may use "named params" (a single hash param).

    I thought that you will anyway modify existing function definitions so, why not having a factory function that makes just what you want:

    
    
    
    
    
    
    
    
    
    
    
    
    

    Hope it helps.

提交回复
热议问题