hanki.dev

The difference between method and function

Function is independent and you call it by its name.

// Define
const foo = () => 'bar';
// Call
foo();

Method is part of an object, and you call it through the object.

// Define
const obj = {
    foo: () => 'bar',
}
// Call
obj.foo();

#misc