For variables containing multiple
words, we write all the words
together without spaces.
To distinguish each word,
we capitalize the first alphabet
of all the words,
except for the first word.
This is known as camelCase.
Let's take a look at another example:
In the example given above,
we use lengthOfBox
without spaces between the words
because length of box
is not a valid name.
Variable names cannot contain spaces.
We will be naming variables
using the camelCase
in all the JavaScript courses.
Here are some other examples
of names using camelCase -
firstName
, lastName
,
temperatureInCelsius
,
fruitsWithRedColor
.
Please note that in JavaScript,
camelCase has become a widely
accepted way of naming variables.
Although this is not defined as a rule,
it has evolved as a community practice,
and
this is what we will follow.