Skip to content

Method

Easy — everyone uses thisGeneral Dev

ELI5 — The Vibe Check

A method is just a function that belongs to an object or class. Your Dog object has a bark() method — it's the dog's personal function. A regular function floats free; a method is attached to something.

Real Talk

A method is a function defined inside a class or object. It typically operates on the data (state) of that class via this or self. Methods define the behaviour of objects in object-oriented programming.

Show Me The Code

class Calculator {
  add(a: number, b: number): number {
    return a + b;
  }
}

const calc = new Calculator();
calc.add(2, 3); // 5

When You'll Hear This

"Call the save() method on the model." / "That method has too many responsibilities."

Made with passive-aggressive love by manoga.digital. Powered by Claude.