使用参数添加函数到数组Javascript(Node.js)

Soh*_*oqi 7 javascript arrays node.js

我想用params将函数推送到数组而不执行它们.这是我到目前为止所尝试的:

 var load_helpers = require('../helpers/agentHelper/loadFunctions.js');
 var load_functions = [];
 load_functions.push(load_helpers.loadAgentListings(callback , agent_ids));
 load_functions.push(load_helpers.loadAgentCount(callback , agent_data));
Run Code Online (Sandbox Code Playgroud)

但是通过这种方式,函数会在推送时执行.该问题提供了类似的例子,但没有参数.如何在此示例中包含参数?

小智 1

推送满足您需求的函数:

load_functions.push(
  () => load_helpers.loadAgentListings(callback, agent_ids),      
  () => load_helpers.loadAgentCount   (callback, agent_data)
);
Run Code Online (Sandbox Code Playgroud)