I’m trying to store callbacks that specify parameters in an array and then execute them sequentially but I don’t really understand how to achieve this in JS.
What I want to do:
<code>var callbacks = [
doThis("foo"),
doThat("bar")
];
function doThis(a) {
...
}
function doThat(b) {
...
}
callbacks.forEach(function(callback) {
callback() // Expression is not callable
});
</code>
<code>var callbacks = [
doThis("foo"),
doThat("bar")
];
function doThis(a) {
...
}
function doThat(b) {
...
}
callbacks.forEach(function(callback) {
callback() // Expression is not callable
});
</code>
var callbacks = [
doThis("foo"),
doThat("bar")
];
function doThis(a) {
...
}
function doThat(b) {
...
}
callbacks.forEach(function(callback) {
callback() // Expression is not callable
});