/**
* 获取函数的形参个数
* @param {Function} func [要获取的函数]
* @return {*} [形参的数组或undefind]
*/
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;
}
}
}
最后
以上就是勤恳钻石最近收集整理的关于javascript 获取函数形参个数的全部内容,更多相关javascript内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复