CallBack & Promises

🎯 Learning Objectives

By the end of this lecture, students will be able to:


#️⃣ 1. What is a Callback Function?

A callback function is a function that is:

Passed as an argument to another function and executed later


🔹 Simple Example

function greet(name, callback) {
console.log("Hello " + name);
callback();
}

function sayBye() {
console.log("Goodbye!");
}

greet("Alex", sayBye);

✔ sayBye is a callback

✔ It runs after greet finishes its work