Sitemap
Kallamadi Shireesha

Kallamadi Shireesha

Trying to share information which I have learned.

Java script 1 — Variables & Identifiers

2 min readMay 10, 2025

I want to share an incident of my neighbours. I give fruits to them since I don’t have any fridge at my home. My neighbour women names are Siri, Esha, Madi.

Siri is type of lady where whatever she takes first she will return that item only, she won’t take other items. Esha and Madi are not like Siri, they will return the exact things which we give and they will take other items also.

In the same way in java script we can store values in three ways using let, var, const

const is like Siri.

let, var are like Esha and Madi.

Get Kallamadi Shireesha’s stories in your inbox

Join Medium for free to get updates from this writer.

Let’s go with the simple examples,

const location = “India”

console.log(variable); //output is “India”

const location = “America”

console.log(variable); // We will get error as shown bellow

Press enter or click to view image in full size

let greet= “Hello world”

greet= “Hello”

console.log(greet); // out put is “Hello”

var direction = “right”

direction = “left”

console.log(direction); // out put is “left”

Variables NAMING convention.

We follow four rules where we call these rules as identifiers.

  1. Unique valriable name: Variable’s name should be unique.

If we give duplicate name we will get the error as shown below.

const variableName = “Hii”;

const variableName = “Hello”;

console.log(variableName);

Press enter or click to view image in full size

2. No Reserved Keywords: For variable declaration we should not use reserved words(eg: let, const, var, function).In the following chapters we will learn reserved keywords in java script

const let = “Hii”;

Press enter or click to view image in full size

3. First letter should be a letter or _ or $: If we assign any other signs it will throw the below error.

const *name = “Siri”

Press enter or click to view image in full size

4. Remaining letters in a variable name should contain only letters or _ or $, otherwise you will get the below error:

const name_of_the_student = “Siri” // valid declaration

const name$ = “Siri” // valid declaration

const name* = “Siri” // invalid declaration

Press enter or click to view image in full size

--

--

Kallamadi Shireesha
Kallamadi Shireesha

Written by Kallamadi Shireesha

Trying to share information which I have learned.