What is an analogy used to explain callback in javascript to a layman person? I am a 13 year old coder trying to explain anonymous functions to people without knowledge of coding how can I explain callback functions without using any technical terms.
-
1Notice that callback doesn't necessarily mean an anonymous function expression. You can first declare a function and then pass it by name as well - that might help for people who aren't too familiar with the syntax.Bergi– Bergi2014-04-03 19:13:49 +00:00Commented Apr 3, 2014 at 19:13
-
an alarm clock is a callback from sleeping when the condition of needing to go to work is fulfilled.dandavis– dandavis2014-04-03 19:38:47 +00:00Commented Apr 3, 2014 at 19:38
Add a comment
|
1 Answer
You go to a library to borrow a book.
They don't have the book since someone already took it.
Instead of waiting for the book for 4 days there, you go home. When they have the book - they call you back.
That's a callback.
2 Comments
Bergi
Isn't it more like giving the library people a sheet of paper where you've noted what to do when the book arrives? You might write "give me a call" or "send book per post" or whatever…
Benjamin Gruenbaum
The library is the one managing it, you're only telling them to call you back, they can have a sheet or whatever alternative they want :)