Reputation: 37
If I have something like this:
dataArray.map(self.aggregationFunction);
but I want to pass the aggregationFunction another parameter, is this possible in Javascript? I tried adding .bind(extra parameter) but it didn't seem to work. Thanks!
Upvotes: 0
Views: 71
Reputation: 131
Rather than passing the function directly, you could pass in a function which calls the function with the additional parameter, e.g:
let someOtherValue = 123;
dataArray.map((dataItem) => aggregationFunction(dataItem, someOtherValue))
Upvotes: 2