Javascript gets the number of function parameters
- 2020-03-30 03:36:55
- OfStack
function getFuncParameters(func) {
if (typeof func == 'function') {
var mathes = /[^(]+(([^)]*)?)/gm.exec(Function.prototype.toString.call(func));
if (mathes[1]) {
var args = mathes[1].replace(/[^,w]*/g, '').split(',');
return args;
}
}
}