map is a built-in JavaScript array method that applies a callback to each element and returns a new array of results. It is an interview-relevant example of functional programming, immutability, and predictable transformation. section 3.2
Pure transformation
const nums = [1, 2, 3]; const doubled = nums.map(n => n * 2); console.log(doubled); // [2, 4, 6] The callback is pure: each input produces the same output without modifying external state. This makes the transformation easier to test, debug, and reason about. section 3.2
Listing 3.6 Using map with a pure function
const nums = [1, 2, 3]; const doubled = nums.map(n => n * 2); console.log(doubled); // [2, 4, 6]
Browse the complete map example showing an array transformation with a pure callback. section 3.2











