Skip to content

Instantly share code, notes, and snippets.

@theatom06
Last active September 18, 2023 05:33
Show Gist options
  • Save theatom06/62b4a5d90346422f443b93869cd2436d to your computer and use it in GitHub Desktop.
Save theatom06/62b4a5d90346422f443b93869cd2436d to your computer and use it in GitHub Desktop.
Naming Scheme in Js

Gandalf's JavaScript Naming Scheme

1. CamelCase:

  • Use camel case for variable and function names.
  • Example: myVariable, myFunction

2. PascalCase:

  • Use Pascal case for class and constructor names and modubles.
  • Example: MyClass, MyConstructor, MyModule

3. ALL_CAPS:

  • Use all capital letters with underscores for constants.
  • Example: MY_CONSTANT

4. Prefixes:

  • Use "is" prefix for boolean variables or functions.

  • Example: isActive, isReady()

  • Use "has" prefix for functions or variables representing presence or existence.

  • Example: hasPermission, hasItems

5. Suffixes:

  • Use "Async" suffix for functions that perform asynchronous operations.

  • Example: getDataAsync(), saveDataAsync()

  • Use "Handler" suffix for functions that handle events or actions.

  • Example: clickHandler, submitHandler

6. _ Underscore Prefix:

  • Use an underscore prefix for internal or private variables.
  • Example: _internalVariable

7. Plural Naming:

  • Use plural nouns for arrays or collections.
  • Example: users, items

8. Verb Naming:

  • Use verbs for functions that perform actions.
  • Example: calculateTotal, validateForm

9. Indentation

  • Use 4 whitespaces in every block on code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment