A pure function always returns the same output for the same input, avoids side effects, and neither modifies nor depends on external state. This determinism makes it predictable, testable, and easier to debug. section 3.2
Impure versus pure JavaScript
An impure function changes external state: `let counter = 0; function increment() { counter++; return counter; }`. By contrast, `function add(x, y) { return x + y; }` depends only on its arguments. Array `map` applies the same idea: `const doubled = [1, 2, 3].map(n => n * 2);` produces `[2, 4, 6]` without modifying the source array.
Use these points to explain the concept in an interview:
- Identify whether a function depends only on its inputs or reads and changes outside state. section 3.2
- Connect immutability and side-effect-free transformations with maintainability, predictable behavior, testing, and debugging. section 3.2
- Explain that functional programming also includes map, filter, reduce, higher-order functions, currying, and partial application. section 3.2
Table 3.2 Core concepts of functional paradigms
|
Topic
|
Fundamentals
|
Applied skills
|
Advanced
|
|
Functional programming
|
Identify pure functions; use
map,
filter,
reduce; explain immutability.
|
Refactor code for immutability; apply currying and partial application; use higher-order functions (HOF).
|
Architect functional modules; optimize performance in functional pipelines; blend FP with OOP patterns.
|
|
Iterators & generators
|
Use
for...of; explain iterators and iterable protocols.
|
Create custom iterators; use
yield to build generator functions.
|
Build asynchronous flows with generators; integrate iterables in advanced design patterns.
|
|
Symbols & meta-programming
|
Explain
Symbol basics and well-known symbols (
Symbol.iterator, etc.).
|
Use
Proxy for validation, intercept API calls; utilize
Reflect API for meta-operations.
|
Architect meta-programming utilities for libraries/frameworks; design extensible APIs with
Symbol and meta-programming.
|
Use the functional-paradigms table to compare pure functions with immutability, higher-order functions, and progressively more advanced functional techniques. section 3.2






















