我正在尝试编写一些js函数的验证。
想法:我具有检查功能,将检查的功能对象传递给它,在此请确保一切正常(或不正确)。我不想单独传递参数,而只传递函数对象。 我怎样才能做到这一点?
现在,我不得不满足于两个用于检查功能的参数-func obj和func参数
那就是我想要的:
function checkFunction(func) {
console.log(func.name);
console.log(func.arguments);
// validate something
}
function checkedFunction(a, b, c) {
checkFunction(checkedFunction...);
// do something
}
这就是我现在拥有的:
function checkFunction(func, args) {
console.log(func.name);
console.log(args);
// validate something
}
function checkedFunction(a, b, c) {
checkFunction(checkedFunction, arguments);
// do something;
}