Test yourself under real exam conditions: 50 timed questions, 60 on the clock, pass mark 70%%. Instant score with a full review of everything you got wrong. Free — no account needed.
Exam details
Functional programming is a declarative programming paradigm that treats computation as the evaluation of mathematical functions. It emphasizes immutability, pure functions, and avoiding side effects. Languages like Haskell, Erlang, Clojure, and F# are primarily functional.
A pure function is a function that:
const add = (a, b) => a + b; is pure, while Math.random() is not.
Side effects are any observable changes a function makes beyond returning a value. Examples include:
Immutability means that once a data structure is created, it cannot be changed. Instead of modifying data, you create new copies with the desired changes. Benefits include:
const newArr = [...arr, newItem]; instead of arr.push(newItem);
Persistent data structures always preserve previous versions of themselves when modified. They use structural sharing to efficiently reuse unchanged portions, avoiding full copies. Libraries like Immutable.js and languages like Clojure provide these. They enable O(log n) updates while maintaining immutability.