Content has been updated elsewhere, would you like to reload?

*** Warning: If you do not reload, you may be editing obsolete contents. This may cause you to lose recent changes.

Yes, reload    |    No, keep this older content
  • Javascript's callback functions is a powerful programming technique. But it remains a mystery to many developers. Let us use many tutorials and examples to get a handle on this useful technique. The popular jQuery library relies heavily on callbacks, and examples are included in the "Chops" section below.

    • What is a JavaScript "callback" function?
    • Why is it special and useful?
    • Why is it said to be easy, yet difficult to grasp?
    • Where can I find useful examples to learn from?
    • How are callbacks used in jQuery library?
  Dishes  - Callback Principles & Examples
  • Dish 1 : Understand JavaScript Callback Functions and Use Them |

  • This is a comprehensive coverage of what Callback is. It is worth spending a couple of days working and replicating the examples here.

    A callback function, also known as a higher-order function, is a function that is passed to another function (let’s call this other function “otherFunction”) as a parameter, and the callback function is called (or executed) inside the otherFunction. A callback function is essentially a pattern (an established solution to a common problem), and therefore, the use of a callback function is also known as a callback pattern.

    ... Because functions are first-class objects, we can pass a function as an argument in another function and later execute that passed-in function or even return it to be executed later. This is the essence of using callback functions in JavaScript

    ... you should look at your own code for opportunities to use callback functions, for they will allow you to:

    • Do not repeat code (DRY—Do Not Repeat Yourself)
    • Implement better abstraction where you can have more generic functions that are versatile (can handle all sorts of functionalities)
    • Have better maintainability
    • Have more readable code
    • Have more specialized functions.
  • (Learn JavaScript Higher-order Functions, aka Callback Functions) In JavaScript, functions are first-class objects; that is, functions are of the type Object and they can be used in a first-class m...
  • Dish 3 : Demystifying JavaScript Closures, Callbacks and IIFEs |

  • This is another comprehensive set of examples, and theory behind callbacks, closures, IIFEs.

    Callbacks are heavily used in JavaScript libraries to provide generalization and reusability. They allow the library methods to be easily customized and/or extended. Also, the code is easier to maintain, and much more concise and readable. Every time you need to transform your unnecessary repeated code pattern into more abstract/generic function, callbacks come to the rescue.

  • Ivaylo Gerchev examines three of the most important and heavily-used concepts in modern JavaScript development — closures, callbacks and IIFEs
  • Dish 7 : Callback Hell |

  • As you can see naming functions is super easy and does some nice things to your code:

    • makes code easier to read
    • when exceptions happen you will get stacktraces that reference actual function names instead of "anonymous"
    • allows you to keep your code shallow, or not nested deeply, which brings me to my next point: ...

  Chops  - jQuery Ajax Callback & Others
  • Chop 1 : How jQuery Works | jQuery Learning Center

  • Unlike many other programming languages, JavaScript enables you to freely pass functions around to be executed at a later time. A callback is a function that is passed as an argument to another function and is executed after its parent function has completed. Callbacks are special because they patiently wait to execute until their parent finishes. Meanwhile, the browser can be executing other functions or doing all sorts of other work.

  • jQuery: The Write Less, Do More, JavaScript Library

  • Chop 2 : Callback Functions in JavaScript - Impressive Webs |

  • This brief example uses jQuery to explain Callback functions. If you want to avoid jQuery for now, skip to Dish #2. 

    You could use this tag to access the publicly-hosted jQuery library at Google:

    <script src=""></script>

  • If you’re fairly inexperienced with JavaScript but you’ve used jQuery, then its likely you’ve used callback functions. But maybe you don’t fully understand how they work or how they’re implemented.

    In this post, which is based on what I’ve learned about callback functions, I’ll try to enlighten you on this fairly common JavaScript technique. 

  • Chop 4 : Understand JavaScript Closures With Ease |

  • Closure is the Javascript structure of inner function that can access it's own variables, the containing function's variables, and the global variables. This is the foundation of callBack functions.

    "Closures allow JavaScript programmers to write better code. Creative, expressive, and concise. 

    ... One of the most important and ticklish features with closures is that the inner function still has access to the outer function’s variables even after the outer function has returned."

  • Closures allow JavaScript programmers to write better code. Creative, expressive, and concise. We frequently use closures in JavaScript, and, no matter your JavaScript experience, you will undoubte...
  References and More

You are welcome to

  • Sign in through   Sign in or sign up with your Facebook account   Sign in or sign up with your Google account   Sign in or sign up with your Amazon account
  • Create your own Web list!
  • Save this into your reading list.
  • Write a comment below.
  • Share this Web list through email or with other Readish users.
Course info
9  4  0  2  0
Language: EnglishThis course is owned by Durio
By Durio

Tags for this course
Suggested courses    Hide
  • Move to:
Open All         >>