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
Solution that is less error prone to spaces and comments would be:
var fn = function(/* whoa) */ hi, you){}; fn.toString() .replace(/((\/\/.*$)|(\/\*[\s\S]*?\*\/)|(\s))/mg,'') .match(/^function\s*[^\(]*\(\s*([^\)]*)\)/m)[1] .split(/,/) ["hi", "you"]