I\'m looking to do the equivalent of Python\'s inspect.getargspec() in Javascript.
I do know that you can get the arguments list from a Jav
The following function will return an array of parameter names of any function passed in.
function getParamNames(func) {
var funStr = func.toString();
return funStr.slice(funStr.indexOf('(')+1, funStr.indexOf(')')).match(/([^\s,]+)/g);
}
Example usage:
getParamNames(getParamNames) // returns ['func']
getParamNames(function (a,b,c,d){}) // returns ['a','b','c','d']