Lorenzo
Lorenzo

Reputation: 29427

Calling a 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 somebody help me on

Giving advice regarding the solution, if there's a better one, etc.

thanks a lot!

Upvotes: 11

Views: 15376

Answers (1)

ChaosPandion
ChaosPandion

Reputation: 78292

It is actually quite simple.

function callback() {
    alert("I am in the callback!");
}

function work(func) {
    alert("I am calling the callback!");
    func(); 
}

work(callback);

Upvotes: 20

Related Questions