0
Can we pass a function with parameters as a callback function ?
2 ответов
+ 5
No if you do that it will call the function you put as an argument itself, plus that beats the purpose
0
You can pass arguments to a callback by wrapping it in another function. I've made a little, basic demo.
https://code.sololearn.com/Wn4Y7HVdUkcU/?ref=app
Being able to handle arguments is very useful for callbacks, just as for other functions. For example, several in-built array methods take a callback function with multiple parameters. E.g. map, filter, reduce etc.