So in any language, there is a set of rules for naming a variable, today we will see about some of those rules or otherwise called naming conventions of a variable.
- When it comes to alphabets we can make use of both upper and lower case (eg: a-z, A-Z).
- When it comes to numbers we can use from (eg: 0-9).
- When it comes to special characters we can make use of two characters one is the Dollar($) sign and the other one is the Underscore(_).
employee customer employee2 $amount _info
Normally you have to keep in mind that a variable should not contain any whitespaces (tabs or spaces).
first name //not allowed user profile //not allowed
A variable cannot begin with a number.
1user //not allowed 10products //not allowed
Reserved keywords are also strictly prohibited to be used as a variable naming convention. These are all the words that are already available in the language which cannot be used for custom purposes.
Array function Object
Always use meaningful names to be much ease for the coding environment and anyone who views the code from the non-technical area. All variables are case sensitive which means we have to be precise when calling the variable in the field of case. You cannot name a variable val and call it Val.
use user instead of u use orderItems instead of oI employee instead of e
firstName userInfo orderDetails finalInput