What are the use cases for closures/callback functions in Javascript?

Posted by Christopher Altman on Stack Overflow See other posts from Stack Overflow or by Christopher Altman
Published on 2010-04-12T13:34:34Z Indexed on 2010/04/12 13:43 UTC
Read the original article Hit count: 481

I was listening to Crockford's talk on Javascript closures and am convinced of the benefit of information hiding, but I do not have a firm understanding of when to use callback functions.

It is mostly a true statement that a person could accomplish the same functionality with or without callbacks.

As someone who is writing code, what heuristics or cues should I keep in mind when determining when to use callbacks/closures?

I am not looking for the blanket statement 'Closures make more secure code', rather a list of practical examples or rules of thumb for when callbacks are the right idea.

Crockford's Presentation: http://www.yuiblog.com/blog/2010/04/08/video-crockonjs-5/

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about callback