0

I am unable to understand the working of the call-backs for the below codes:

http.createServer(function(request,response){ . . . });

Another example could be :

navigator.geolocation.getCurrentPosition(function(position){. . .});

I am unable to understand where are the request,response and position popping up from in such kind of call-back functions.

Could somebody give a simple general example where the call-back functions are called with parameters and are in the above format.(I am just confused with the style in which the call-back functions have been called with parameters).

  • `createServer()` and `getCurrentPosition` will somewhere down the line call the function that you passed as a parameter. When it calls this function it will supply those values which you then can access in your callback function. [This answer](https://stackoverflow.com/a/34624677/479156) has a nice example. – Ivar Jul 07 '21 at 17:11

0 Answers0