Back to Developer Roadmap

Variable Naming Conventions

src/data/question-groups/javascript/content/variable-naming-conventions.md

4.0678 B
Original Source

The following are the naming conventions for variables in JavaScript:

  • Write variable names in camelCase. Use lowercase letters to begin the variable name and then uppercase for each new word, e.g., myName.
  • Use descriptive variable names. Instead of using "p" as a variable name for a password, use userPassword instead.
  • Don't use JavaScript keywords such as if, for, or while as variable names.
  • Don't include special characters like punctuation and math operators in your variable names. Only use underscores (_) and dollar signs ($).
  • Don't start variable names with numbers; instead, place them at the end. For example, you can't have 99myName, but myName99 is okay.