Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Complete rundown (stuck)

This will be lengthy. I just finished the course AJAX. I'm on Asynchronous programming with JS. I'm very confused by this. What is a callback? It's a function aka parameter passed into another function correct? How do you call one? What is the purpose of using a callback? What's the logic behind it?. What is passing a reference to an event listener? This whole course confuses me, If someone can simply explain it to me like break it down simply that would me alot.

Hey reggie, i'm going to finish that course you recommended when i can and if i still don't understand it i'll come back to this and let you know. Thank you for helping.

1 Answer

Reggie Williams
STAFF
Reggie Williams
Treehouse Teacher

Hey Nas Jones you're correct! A callback is a function that is passed into another, similar to event handlers.

You can pass one function into another as a parameter as you mentioned and call the function in the body of the other. Using a callback gives us more control over when a function runs. In the case of event handlers, the function is called only when the event happens. If you haven't done this course it may be helpful before working on the asynchronous lessons