首页 > 解决方案 > 调用函数(需要参数)作为参数

问题描述

我有一个接受另一个函数作为参数的函数,所以我可以像使用它一样使用它

waitFor(something)

在哪里const something = async function(){...}

如果something是一个带参数的函数呢?我将如何使用它waitFor

如果我这样做,waitFor(something(id)我会收到错误the fn described in waitFor is not a function.,因为something(id)不是函数而是函数调用,对吗?

标签: javascriptasynchronousasync-await

解决方案


waitFor(function(){ return something(id); });


推荐阅读