My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
Imagine A variable, for better understanding

Imagine A variable, for better understanding

This article will help you to understand the basic concepts which are difficult for many new coders.

Data_as_Dopamine's photo
Data_as_Dopamine
·Jul 28, 2021·

2 min read

Variables:

(2 mins reading)

If you are stuck with an imagination how variables are? How do they look like? How they are able to store a value in computer memory and you are stuck to imagine it in your head. You are in the right place to understand it.
Have you seen a vessel, a simple container? They are able to contain anything you put into them. They are unaware of the thing placed into them. They just provide the space to that place according to the size of the place. Just imagine! a place or a container you can put in the computer memory. In very common terms Imagine that memory is your refrigerator and you are putting your vessel in that. Similarly, you are putting that container into computer memory, that container can store anything. The space consumed by the thing you put into a container is equivalent to its size.

food/ water in a vessel, a vessel into the refrigerator

num/character/ string/float into variable, variable into computer memory

So, the variable is just a container and it has now different types, it stores that specific data type into that specific type of variable. As you can only store the liquid in the bottle and solid food has a bowl or container or box in which it can be stored.

Be careful about the naming convention of variables a clear and meaningful name will increase readability and will enable you to remember things in the future.

It plays a vital role in learning

Number = 321, Name = Fareeha

Here both variables Name and Number convey clear meaning.

As the box in which you store your lunch, you call it lunch box, If you are putting rice in anything you call it a serving dish giving them names that are not understandable won't convey clear meaning.

I hope this may clear your concept regarding different types of variables!

Happy Reading! Keep coding daily while making it fun for you!