3 ms·
The term "callback" is usually used to refer to a function that you want called after the completion of an async operation (like a database read, a file read, a
by interblag 6y ago
The term "callback" is usually used to refer to a function that you want called after the completion of an async operation (like a database read, a file read, a network call, etc).
This article uses the term callback but then uses functions passed to "map" as its examples; "map" is synchronous and so this usage of the term "callback" is atypical, probably atypical to the point that we can just say it's incorrect :).
- bryik 6y agoFWIW, Wikipedia's defines "callback" as "any executable code that is passed as an argument to other code; that other code is expected to call back (execute) the argument at a given time" and synchronous callbacks are mentioned explicitly [0]. I don't think Jake's usage of the word is atypical. 0 - https://en.wikipedia.org/wiki/Callback_(computer_programming) https://en.wikipedia.org/wiki/Callback_(computer_programming...
- Chris_Newton 6y agoThe term "callback" is usually used to refer to a function that you want called after the completion of an async operation I’m not aware of any authoritative definition, but the term “callback” has been used for functions passed in as parameters to higher-order functions since long before the modern idioms for asynchronous code were around. The first use of the term I can remember personally was for the comparator function passed to qsort in C. That was probably sometime in the 1980s. Another common usage that goes way back is for event handlers in event-driven systems.
- spion 6y agoExactly, the term typically used for the specific type of callback being discussed here is a "continuation callback", and the specific style is "continuation passing style" The term is actually used correctly; callback's definition is broad. Of course, noone can resist the temptation to berate members of the JS community.