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

Charlie Prator
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Charlie Prator
Front End Web Development Techdegree Graduate 19,854 Points

What does Chalkley mean when he says that the anonymous function is "more expressive"?

Chalkley mentions that writing a callback function inline and anonymously makes it more expressive. Here's the function he's referencing in the video:

executeCallback(function () { console.log('Hello'); });

2 Answers

Steven Parker
Steven Parker
215,954 Points

I think he explains it himself right after that, and what he means is that it's vary obvious that what is being passed is a function, where it might not be so clear if you were passing just a reference.

Eddie Harmon
seal-mask
.a{fill-rule:evenodd;}techdegree
Eddie Harmon
Web Development Techdegree Student 17,043 Points

Another way that I personally understand it is that maybe he is saying that anonymous functions are more "explicit". It is direct, clear, whereas if you utilize a named function, unless you look at the code directly, it is easier to mistake as potentially being a variable. But, with an inline, anonymous function, you cannot make that mistake since it is explicit (and not implied via a "name") aka "more expressive".