Javascript Basics Part 2
Arya Krishna
Posted on April 24, 2022
One of the most important building block of any application is a variable. Beginners usually get confused between variables and their values.
var studentName = "Arya";
Here the var studentName is the variable and Arya is the value that is assigned to that variable.
One of the great tips that I received during my bootcamp classes was that think of a variable as labeled boxes with something placed inside of them. So, declaring a var without value is like having an empty box labeled without anything inside of it. But we know what exactly should we be filling inside the box. The contents of this box could be replaced with another contents.
Always keep a clear mental separation between the concept of variables and their values. Variables are not values themselves, they help us hold or contain the values.
In typical variable naming convention we don't use any special characters but we use something called as camel cased.Camel Case refers to the internal capital letters, which resemble the humps on a camel's back. For example, happinessProject, computerScience, and WordPress are all examples of CamelCase.
Another best practice is to declare the variable in the beginning of the application. This helps the application and ourselves to have an idea of what we are going to use, and what we are planning to modify. Declaring a variable as I said before just gives us an empty container, it doesn't have any meaning since there is no values assigned to the variable. If we redeclare the same variable name twice, it just means we have thrown the first one in trash or that it is of zero importance now since we have redeclared it to a different value.
We are declaring the variable because that makes it possible for us to reuse them throughout our application.
Posted on April 24, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.