# 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:

```javascript
//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.

```javascript
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.

![](https://miro.medium.com/v2/resize:fit:1400/1*lrRGwpimwMttCpzzDddCXA.png align="center")

```javascript
//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.

```javascript
const firstName = Nithin
console.log(`${firstName} is a programmer. ${firstName} is 23 years old. ${firstName} is part time instructor`)
```
