Method
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."
Related Terms
Class
A class is a blueprint for creating objects.
Function
A function is a reusable recipe. You write the steps once, give it a name, and call it whenever you need those steps done.
OOP (OOP)
OOP is a way of organising code by modelling the world as objects — things that have properties (what they are) and methods (what they do).
Parameter
A parameter is the placeholder name inside a function definition — it's the label on the slot where you plug things in.
Return Value
A return value is what a function hands back to you after doing its work. You send a coffee machine beans and water, it returns coffee.