From the course: Learning Functional Programming with JavaScript (ES5)
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Chapter introduction - JavaScript Tutorial
From the course: Learning Functional Programming with JavaScript (ES5)
Chapter introduction
- [Narrator] The ability to pass functions in JavaScript has some very useful implications for performing asynchronous tasks, such as reading or writing files, working with databases, or making network requests. The normal synchronous way of reading files, for example, requires that the file operation be fully completed before any other code is executed. So in this example, the second line won't be called until the first line completes. In many cases this can take several seconds or even several minutes. This can of course have detrimental effects on user experience, since it holds up the entire program until it's finished. The answer is to use asynchronous tasks, tasks that don't hold up the rest of the program. Lucky for us JavaScript provides a very convenient way of handling asynchronous tasks. This is through the use of callbacks. A callback is simply a function that you pass as an argument to an asynchronous function. When the asynchronous function finishes running, it simply…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.