javascript - 开玩笑监视数组元素
问题描述
我将函数存储在一个数组中。在我的测试中,我需要监视该数组中的函数。这可能吗?
const myArray = [];
myArray.push(() => {
console.log('first');
});
myArray.push(() => {
console.log('second');
});
例如,我将如何监视上面代码中添加到数组中的两个函数?
解决方案
推荐阅读
- c# - C# 跟踪完成的日常任务
- python - 在文本文件中查找字符串的函数(Python)
- node.js - 如何在 Mongoose 的对象数组中查找和删除特定对象
- yaml - YamlDotNet“预期'StreamEnd',读取字符串时得到'DocumentStart'”
- ios - 在 UITableViewCell 上滑动时如何配置阈值/距离
- c# - 禁用标题栏“X” - 关闭按钮
- javascript - 如何使用 webpack 和 ReactJS 使可扩展菜单工作
- c# - 为什么我不能 ILMerge Zxing?
- python - Python ctypes:类型转换
- ios - React-native-maps lite 模式在 Ios 模拟器上不起作用