DEV Community

Cover image for Variables and Datatypes In JavaScript-series-1a
Santhi Sri Jamisetty
Santhi Sri Jamisetty

Posted on • Updated on

Variables and Datatypes In JavaScript-series-1a

Photo by Maureen Sgro on Unsplash

What are variables? Why do we need them in programming.

Variables are containers (a memory location)as seen above in the color palette to store values and access them whenever required.

So what type of values our variables store?

Any value or any piece of information our containers can store. As in the color-palette which can store any color and remove the color, similarly, in variables we can rewrite the values as per the requirement.

Again the information stored in variable can be of same type, called "Primitive type" as in example 1 which stored a string.We'll get it to later when we learn about the data types.
Or the other type includes collections called "Objects" which hold different types together. Like when you work with excel file or database table the entire record or row is a collection which constitute numbers, null values, string etc. as in example 2

var myName = "Santhi"; ------example 1-Primitive type

First Name Last Name Registration Cost
Sean Forbes $1600
Jack Rogers $985
Andy Young
          ...To be continued in series 1b.
Enter fullscreen mode Exit fullscreen mode

Oldest comments (0)