A pure function always returns the same output for the same input and has no side effects:
// Pure - same input always gives same output
function add(a, b) {
return a + b
}
// Impure - depends on external state
let multiplier = 2
function multiply(x) {
return x * multiplier // Result depends on global
}
Pure functions are easier to test and debug. They're predictable because they don't depend on or modify external state.