# What's the difference between a method and a function?

> Learn the difference between a function and a method in JavaScript: a method is a function stored on an object property that can access it through this.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2020-06-12 | Topics: [JavaScript](https://flaviocopes.com/tags/js/) | Canonical: https://flaviocopes.com/javascript-difference-method-function/

A function lives on its own:

```js
const bark = () => {
  console.log('wof!')
}

bark()
```

or

```js
function bark() {
  console.log('wof!')
}

bark()
```

A method is a function assigned to an object property:

```js
const dog = {
  bark: () => {
    console.log('wof!')
  },
}

dog.bark()
```

The method can access the object properties, but only when it's a regular function, not an arrow function:

```js
const dog = {
  name: 'Roger',
  bark: function () {
    console.log(`I am ${this.name}. wof!`)
  },
}

dog.bark()
```
