Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Callback Functions in JavaScript Introduction to Callback Functions Anonymous Functions

Tomasz Grodzki
Tomasz Grodzki
7,705 Points

I don't see difference between function and callback function, except syntax

Andrew said, that this function below could get executed at any point in the future.

executeCallBack ( function () {

Well... Next function, also could be invoke at any point in the future. So what's the point of using callback function? As far, everything that was said about callback I could do without callback. Launching function at some, specific point of program does require some e.g. conditional statements or event listener, what's the difference if I use callback or no?

 function sayHello() {

1 Answer

Steven Parker
Steven Parker
215,372 Points

A "callback" is simply a function that is passed to another function as an argument. The other difference is that you generally don't invoke callbacks yourself. That is done by the function that you pass it to.