r/learnjavascript • u/RobGoLaing • Oct 24 '26
Some notes on callbacks
I've written some notes on callbacks as part of my effort to write tests and be methodical in learning JavaScript.
Callbacks are one of those things that are quite easy once you go "Aha", but like probably most people, I found them very confusing at first.
12
Upvotes
View all comments
1
u/senocular Oct 24 '26
FWIW not all functions passed in as arguments are callbacks and not all callbacks are functions that get passed into other functions.
Web components for example have callbacks that are methods of the class used to define the component, ex:
And addEventListener also accepts objects as listeners, where the callback is a method of the object rather than being the argument itself.