Lesson 173 – Complete 2020 Web Development Bootcamp

Lesson 173 – Understanding Callbacks and How To Respond to Events

Javascript allows us to create Higher Order Functions. A Higher Order Function is a function that is able to take functions as inputs.

A function that gets passed in as an input is called a Callback Function.

In the following example, “.addEventListener” is a Higher Order Function and “respondToKey(event)” is a Callback Function.

document.addEventListener("keydown", respondToKey(event));
function respondToKey(event){
 console.log("Key pressed.");