How to Name Variables: Best Practices Explained

RAJU KUMARRAJU KUMAR
2 min read

Variable/Function Naming Conversion

Variable naming is one of the most important parts of coding, yet it's often overlooked by many. While it doesn't directly impact a code's efficiency, it significantly enhances readability and code quality. Clear and meaningful variable names facilitate easier debugging and ultimately contribute to the overall improvement of code quality.

Types of naming conventions

There are numerous variable naming conventions in the coding world, but among the most important are :

a) Camel Case

b) Pascal Case

c) Snake Case

d) Kebab Case

Camel Case

Camel case is a variable naming convention used almost everywhere during variable naming where words in a phrase are combined without spaces.

In camel case, the first letter of each word in a phrase is capitalized except for the first word, which starts with lowercase. There are no spaces between the words.

Examples of Camel Case

Pascal case

Pascal case is another naming convention we use frequently to combine the words in a phrase without using spaces. It is similar to the 'Camel Case' convention just with a slight difference.

In this naming convention each word in a phrase is capitalized including the first word.

Examples of Pascal Case

💡
'Pascal Case' naming convention is also known as 'Upper Camel Case'.

Snake Case

Another very famous variable naming convention is 'Snake Case' convention. This naming convention is most preferred in programming languages like Python.

In snake case, all the words of a phrase are written in lowercase and separated by underscores("_") instead of spaces.

Examples of Snake Case

Kebab Case

The kebab case is almost similar to the snake case where all the words in a phrase are written in lowercase.

The only difference between snake case and kebab case naming convention is, In kebab case the words in a phrase are separated by hyphens("-").

Examples of Kebab Case

Conclusion

Okay, so this was a small and concise article that we need to understand before we start coding in JavaScript. As mentioned earlier, these concepts may seem insignificant, but they are crucial for writing quality code. That's all from this article. See you in the next one. Keep learning!.

0
Subscribe to my newsletter

Read articles from RAJU KUMAR directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

RAJU KUMAR
RAJU KUMAR