0

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!

1 Answer 1

2

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))
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I knew I had seen this earlier. Worked like a charm!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.