0Pricing
TypeScript Academy · Lesson

Pure Functions and Immutability

Write predictable functions without side effects.

What Is a Pure Function?

A pure function returns the same output for the same input and has no side effects. It does not read or write external state, mutate its arguments, or perform I/O.

A Pure Example

This function depends only on its arguments and produces only a return value. Calling it never changes anything outside.

function add(a: number, b: number): number {
  return a + b;
}
console.log(add(2, 3)); // 5, always

All lessons in this course

  1. Pure Functions and Immutability
  2. Currying and Partial Application
  3. Function Composition with Types
  4. Typed pipe and flow Utilities
← Back to TypeScript Academy