- Write concise arrow functions
- Understand callback fundamentals
- Use callbacks with array methods
- Recognize synchronous flow with callbacks
- Practice cleaner modern JavaScript
BMC201 - Web Technology
2026-02-19
Lecture 16
Arrow Functions & Callbacks
Week 4 | Unit II: JavaScript Functions & Events
BMC201 - Web Technology
Mr. Prashant Kumar Nag, Assistant Professor
Learning Objectives
Arrow Function Syntax
const add = (a, b) => a + b;
const square = x => x * x;
const greet = () => "Hello";
const full = (first, last) => `${first} ${last}`;Arrow functions are compact and readable for small logic.
Regular Function vs Arrow
Both work; arrow syntax is shorter in many cases.
What Is a Callback?
A callback is a function passed into another function.
Array Methods with Callbacks
const nums = [1, 2, 3, 4, 5];
const doubled = nums.map(n => n * 2);
const evens = nums.filter(n => n % 2 === 0);
const total = nums.reduce((acc, n) => acc + n, 0);map: transformfilter: selectreduce: combineforEach with Arrow Function
const students = ["Asha", "Vikram", "Neha"];
students.forEach((name, index) => {
console.log(index, name);
});Useful for side effects like logging or UI updates.
Callback Flow Pattern
Common Mistakes
callback() instead of callbackthis from method context is neededPractice Task
Write a function transformNumbers(arr, callback) that:
Questions?
Next: Week 5 - DOM Manipulation