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

Don't totally understand this

Hi, so I am getting all my genres but I don't entirely understand this line of code

// get genres 
module.exports.getBooks = function(callback, limit) {
    Genre.find(callback).limit(limit);
};

function(callback, limit) what's the callback?

1 Answer

Steven Parker
Steven Parker
243,656 Points

A callback is another function.

It is generally an anonymous function, or just the name of a previously defined function, that is passed as an argument to a function. The function to which it is passed generally performs some task that takes some time, and the callback function is invoked when the task is complete.