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 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
231,269 Points

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

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".