javascript - 调用函数(需要参数)作为参数
问题描述
我有一个接受另一个函数作为参数的函数,所以我可以像使用它一样使用它
waitFor(something)
在哪里const something = async function(){...}
如果something
是一个带参数的函数呢?我将如何使用它waitFor
?
如果我这样做,waitFor(something(id)
我会收到错误the fn described in waitFor is not a function.
,因为something(id)
不是函数而是函数调用,对吗?
解决方案
waitFor(function(){ return something(id); });
推荐阅读
- python - if 是 Python 中的函数或运算符
- gitlab - 在 gitlab-ci 中创建合并请求时触发新管道
- pyspark - 展平嵌套数据框并重新转换为原始形式
- excel - 在excel vba中查找字母数字之间的前2个最大值
- c++ - 从字符串数组写入文本
- python - Python 从 __module__ 获取父模块
- java - 即使使用 @Bean 注释进行 Bean 创建,@Autowire 也不起作用
- vue.js - Vue js 3 将数据 beetwen 传递到不同的页面
- typo3 - Typo3 9.5:语言回退不适用于网格元素
- javascript - 安装后的 Npm 错误