Suppose I have the following code:
Synchronous Version:
var waitingToGetValue = heavyProcessingFunc (para1, para2);
response.send(waitingToGetValue);
I tried looking around but all I got were functions without parameter.
Asynchronous Attempt:
heavyProcessingFunc(para1, para2, (function(waitingToGetValue){
response.send(waitingToGetValue);
});
I need to send the two parameters to the function. The function returns a value that I need to use to then send it to the response.
Does it even matter if I put it in a asynchronous format? Can anyone recommend me a video/source that easily explains the difference synchronous vs asynchronous: I read many material for the past few days and it just keep getting more confusing with promises, callbacks, and trying to access the values outside those functions.