JAVASCRIPT Tutorial

Naming Conventions

Practical Steps:

  1. Use meaningful names: Choose names that clearly describe the purpose or function of the object.
  2. Use camelCase or PascalCase:
    • camelCase: lowercase first letter, capitalize subsequent words (e.g. myFunction)
    • PascalCase: all letters capitalized (e.g. MyFunction)
  3. Be consistent: Maintain the same naming style throughout your code.

Key Concepts:

  • camelCase: Commonly used for variables, function names, and CSS class names.
  • PascalCase: Used for class names and constructor functions.
  • Meaningful names: Avoid generic or ambiguous names (e.g. data, temp).

JavaScript Example:

// Use descriptive and consistent naming
const fullName = "John Doe";
const getAge = function() { return 30; };
class Person {
  constructor(name, age) {
    this.name = name;
    this.age = age;
  }
}