One new thing I learned today: Callback in Javascript (part I)

Callback in Javascript (I just noted it from what I read, it’s not original writing from me)

function in JS: it acts as any other Objects,

It can be stored in variables, passed as arguments to functions, created within functions, and returned from functions”

A callback function is passed to another function (a.k.a otherFunction) as a parameter and the callback function is executed inside that otherFunction.

a callback function is like a Worker who “calls back” to his Manager when he has completed a Task.

When we pass a callback function as an argument to another function, we are only passing the function definition.

since the containing function has the callback function in its parameter as a function definition, it can execute the callback anytime.

Note that the callback function is not executed immediately. It is “called back” at some specified point inside the containing function’s body.

…humm enough for today, I will check it thoroughly tomorrow.



One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.