From the course: Learning the JavaScript Language

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Callback functions and looping

Callback functions and looping - JavaScript Tutorial

From the course: Learning the JavaScript Language

Callback functions and looping

- [Instructor] In this video we're going to talk about callback functions. We've seen these in use a couple of times but I want to give them a little specific attention because they're used a lot in modern JavaScript. Callback function is a piece of jargon, meaning a function that's passed as an argument, into another function and executed in that function. Because functions are first class citizens in JavaScript, you'll see this all over the place. Here's a function called doubleIt which takes a number and returns it multiplied by two using the multiplication assignment operator. And then here's a variable called myNumbers with the digits one through five in it. A start up node down here. And let's bring these in. Copy and paste so we have them available. JavaScript arrays have a method called map that takes a callback for the parameter. That callback has one required parameter itself, the item in the array that we're…

Contents