JavaScript Is Sexy
Master JavaScript and Frontend Development
  • Recent Posts
  • About/Contact
  • All Posts
Menu
JavaScript Is Sexy
Master JavaScript and Frontend Development
Tag

Callback Functions

16 Important JavaScript Concepts

Understand JavaScript Callback Functions and Use Them

avatar
Richard Bovell·March 4, 2013

(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 manner like any other object (String, Array, Number, etc.) since they are in fact objects themselves. They can be “stored in variables, passed as arguments to functions, created within functions, and returned from functions”1.
[sc:mongodb-book]

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. In the rest of this article we will learn everything about JavaScript callback functions. Callback functions are probably the most widely used functional programming technique in JavaScript, and you can find them in just about every piece of JavaScript and jQuery code, yet they remain mysterious to many JavaScript developers. The mystery will be no more, by the time you finish reading this article.

Callback functions are derived from a programming paradigm known as functional programming. At a fundamental level, functional programming specifies the use of functions as arguments. Functional programming was—and still is, though to a much lesser extent today—seen as an esoteric technique of specially trained, master programmers.

Fortunately, the techniques of functional programming have been elucidated so that mere mortals like you and me can understand and use them with ease.

Read more
215 comments  Like

Receive Updates

In Collaboration With

  • Recent Posts
  • About/Contact
  • All Posts

© 2018 JavaScript Is Sexy

Site Designed By Sam Chittenden

Close
  • Recent Posts
  • About/Contact
  • All Posts