Values and variables in JavaScript

Values
Values are piece of information or piece of data that all of us are mainly focused on. every business runs based on data. There are different types of data available in JavaScript. They are:
//These are the different types of data available in JS
console.log('Nithin')
console.log(23)
console.log(true)
console.log(false)
console.log(undefined)
console.log(null)
Variables
These data or values can be stored inside a variables. As shown in the example below. main purpose of using variables is because of its reusable and can be used anytime as we want. and these variables will create a memory at our system.
const firstName = 'Nithin'
console.log(firstName)
console.log(firstName)
console.log(firstName)
Analogy
Think of variables as a box or container inside which you can store some valuable items and give a specific name to it. so that when you need to use it for next time, you can remember the name written on the box and directly open it.

//print the following outout
console.log(`Nithin is a programmer. Nithin is 23 years old. Nithin is part time instructor`)
// and change the name Nithin to Virat.
Lets check the challenge above. just imagine how difficult it would be if we dont have any variables in programming language. then we should have been repeating the above statement. one after the other. and if we want to change the name, then again we have to change the name in all the places. In this place variables help us by reducing the repeating tasks.
solution to the above.
const firstName = Nithin
console.log(`${firstName} is a programmer. ${firstName} is 23 years old. ${firstName} is part time instructor`)
About the author
Aspiring Full stack developer
Comments
Join the discussionNo comments yet. Be the first to comment.


