Jan 31 20231 min read
Superficial guide to naming variables (JS/TS)

Blogs

Superficial guide to naming variables (JS/TS)

  • Boolean variables - use a helping verb as a prefix
    • Ex. isChecked, isOpen, willToggle
  • Function names - use a verb as a prefix
    • Ex. checkIsValid, submitPost, fetchPost
  • Keep variable names descriptive enough
  • Declaring variables
    • Use const for declaring by default
    • Use let if variable is going to be reassigned
    • Never use var
  • Its okay if variable names are long