Callback functions are a core part of how a lot of modern JavaScript methods work. But what exactly are they? A callback function is just a function that another function runs (either immediately or a later time). For example, consider the
A lot of methods that modify arrays ( For example, here the
The examples above use anonymous callback functions. A new unnamed function is created and passed directly into the method. But you can also predefine a named function and pass that in as a callback function instead. When you do, omit the the parentheses ( The method that's using it will run it when needed.
Looking at this code, you might also wonder: where do the arguments passed into the callback functions come from? We'll talk about that tomorrow! Like this? A Go Make Things membership is the best way to support my work and help me create more free content. Cheers, Want to share this with others or read it later? View it in a browser. |
0 Komentar untuk "[Go Make Things] What is a callback function?"