Naming conventions

A naming convention is a shared rule for naming variables, functions, files, classes, and other parts of a project. Clear names help you understand code without guessing.

What you will learn

Choose names that explain purpose

const userName = 'Yugien';
function getUserProfile(userId) {
  // fetch and return the profile for userId
}

userName and getUserProfile tell a reader what the value and function are for. Avoid names such as x, data2, or doThing when a more precise name is easy.

Common casing styles

camelCase
Starts lowercase and capitalizes later words. Common for JavaScript variables and functions: userName.
PascalCase
Capitalizes each word. Often used for classes or components: UserProfile.
snake_case
Uses underscores. Common in Python and some data formats: user_name.
UPPER_SNAKE_CASE
Often used for constants: DEFAULT_TIMEOUT.
kebab-case
Uses hyphens. Common in URLs, CSS, and data attributes: user-profile.

Rules worth agreeing on