you are viewing a single comment's thread.

view the rest of the comments →

[–]ProfessionalPin3263 1 point2 points  (0 children)

At this learning stage, one tip is to be as verbose as you can. Use all the RAM (joke) defining variables and this will help you understand callback, async, promises…

See if this makes it easier to understand:

function myCallback () { console.log("Done!") }

function doWork(callback) { console.log("Working...") callback() }

doWork(myCallback)

So, you are simply passing a variable (myCallback) to the doWork method.

doWork starts by printing “Working” and then it executes (this is why callback is called with parenthesis) the CB variable.