Lingua-e
← Comparisons

function vs method

A function stands alone. A method belongs to a class or object and can access its state. In everyday conversation developers often say "function" for both, but in code reviews and interviews, using "method" when talking about class members sounds more precise.

function

A standalone block of code that can be called by name. It is not attached to any class or object. It exists on its own.

"function calculateTax(amount: number): number { return amount * 0.21; }"

method

A function that belongs to a class or object. It has access to the object's state via "this" (or "self" in Python). All methods are functions, but not all functions are methods.

"class Invoice { calculateTax() { return this.amount * 0.21; } } // calculateTax is a method"

Other comparisons

Was this page helpful?

Ready to practice your English at work?

Lingua-e has interactive exercises built around real developer conversations: standups, code reviews, retrospectives, and more. Practice until it comes naturally.

Try Lingua-e for free