Function vs Method — What's the Difference?

A function is a standalone, reusable block of code that can be called independently; a method is a function that's defined as part of a class or object and o...

Published November 24, 2026

A function is a standalone block of code you call by name; a method is a function attached to an object or class and called on an instance, implicitly receiving that object (this or self).

The concept

Functions stand alone: add(2, 3). Methods belong to a type: user.save(). Inside a method you can access the object's data.

Some languages (Java, C#) have only methods; others (JavaScript, Python, Go) have both.

Call forms

function: len(items) — data passed in
method: items.append(3) — called on the object

Practical examples

Function

def area(w, h): return w * h
area(2, 3)

Method

class Rect:
    def __init__(self, w, h): self.w, self.h = w, h
    def area(self): return self.w * self.h
Rect(2, 3).area()

JavaScript

function double(n) { return n * 2 }        // function
[1, 2].map(double)                          // map is a method
const o = { say() { return this.msg }, msg: 'hi' }

Common mistakes

  • Detaching a method from its object and losing this.
  • Using methods where a pure function is simpler.
  • Confusing static methods with instance methods.

Key takeaways

  • Function = standalone, method = on an object.
  • Methods get the instance implicitly.
  • Static methods belong to the class.

FAQ

What is a static method?

A method on the class itself that does not use an instance.

Are arrow functions methods?

They can be properties, but do not bind their own this.

More General articles