DEV Community

Cover image for Javascript Basics Part 2
Arya Krishna
Arya Krishna

Posted on

4 3

Javascript Basics Part 2

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";

Enter fullscreen mode Exit fullscreen mode

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.

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay