# JavaScript Naming Conventions

> Suggestions and guides for naming in JavaScript.

- Canonical: https://dennisokeeffe.com/blog/2018-10-22-js-naming-conventions
- Published: 2018-10-22
- Updated: 2018-10-22

```bash
[verb = required][verb = null][noun = null][preposition = null][noun = null]
```

## Verb examples

- get
- save
- fetch
- throw
- remove

## First noun examples

- user
- image
- data
- item

## Prepositions

- from
- to

## Second noun examples

- database
- table
- copy

## In usage

The `[noun][preoposition][noun]` may not always need to be used and simplicity is the goal if possible.

```javascript
// high specificity examples [verb][noun][preposition][noun]
getUserFromDatabase();
saveUserToDatabase();
saveImageToTable();
fetchRestaurantFromCopy();

// omitting the preposition and second noun [verb][noun]
removeItem();
getResult();

// omitting all except verb [verb]
signIn();
signOut();
signUp();

// using the first verb [verb][verb]
confirmSignIn();
confirmSignUp();
```
