Surendar Vinayagamoorthy
Surendar Vinayagamoorthy

Surendar Vinayagamoorthy

Naming Conventions - Javascript

Naming Conventions - Javascript

Cases and their uses.

Surendar Vinayagamoorthy's photo
Surendar Vinayagamoorthy
·Jan 30, 2022·

2 min read

Subscribe to my newsletter and never miss my upcoming articles

Table of contents

  • PascalCase
  • SNAKE_CASE_ALL_CAPS
  • camelCase
  • kebab-case

Naming conventions in Javascript is always a topic of debate. Here's me trying to put my views in my perspective.

Note: Conventions are the set the rules formulated and followed by every organisation or team.

The below image represents various type of cases used in Javascript and we will explore them more in the coming sections.

Naming Conventions.png

PascalCase

  • It is used when representing a class or component
  • Here is the first letter of each work representing the class or component is capitalised.
  • In the example, the first letters of the words "motor" & "vehicle" representing the class is capitalised. PascalCase.png

SNAKE_CASE_ALL_CAPS

  • It is used for holding variables whose values don't change during the execution i.e., const.
  • Here the words are capitalised and the spaces are replaced by underscores (_).

SNAKE_CASE_ALL_CAPS.png

camelCase

  • It is used for representing almost all the other naming conventions which include variables that change (let & var), functions (arrow & conventional), parameters & arguments.
  • This is similar to Pascal case but with the first letter of the first word in lowercase.

camelCase.png

kebab-case

  • It is used for representing the file names, modules w/ versions and dependencies. eg: jquery-1.12.4.js
  • here the words are separated by a hyphen (-) and all lowercase

kebab-case.png

Code snippets are generated using ray.so


Hope you find this useful. Either way, let me know how it could be improved - my DMs are open @radnerus93. Also follow Surendar Vinayagamoorthy for more articles on Javascript, Java & Cloud.

 
Share this