So I get what callbacks are and how they are used, but I dont understand why we need and use them?
than we have to wait to finish it, so asynchronous is a solution to it. Start now and finish later, while the rest of the code (e.g. functions) are executed, if it is synchronous. if the async operation is finished, then it will be executed. Inside we have the callback function and gets called back/executed.
Why I don’t take the return value of the async operation and return it or assign it to a variable and then reuse it? Is this not much better than the callbackhell? Why even we do something like this?
What I heard so far, but didnt understand:
-Flow control, execute code only if async operation is finished
-Callback needs data from the async operation e.g. http request to an api endpoint (but this could be done differently see above)
Maybe someone can help me out
Thanks and greetings