Callback callback in javascript

I am not so strong in javascript.

I have a common function that I call from many parts of my code, passing them some parameters.

Can someone help me on

  • how to define a new parameter for this function, which should be a callback without parameters passed from the caller (for example, many jquery plugins)
  • how to handle callback inside function

Providing recommendations on the decision, if there is the best, etc.

Many thanks!

+6
javascript callback
source share
1 answer

This is actually quite simple.

function callback() { alert("I am in the callback!"); } function work(func) { alert("I am calling the callback!"); func(); } work(callback); 
+11
source share

All Articles