FP — pure functions, immutability. OOP — objects, state.
Functional Programming:
FP:
const add = (a, b) => a + b;
const double = x => x * 2;
[1,2,3].map(double).filter(x => x > 2);
(Pure functions, no side effects)
Object-Oriented Programming:
OOP:
class User {
constructor(name) { this.name = name; }
getName() { return this.name; }
}
(Objects with state)
Key differences: