In computer science, data is anything that is meaningful to the computer. JavaScript provides seven different data types which are undefined, null, boolean, string, symbol, number (int, float and double) and object.
For example, computers distinguish between numbers, such as the number 12, and strings, such as "12", "dog", or "123 cats", which are collections of characters. Computers can perform mathematical operations on a number, but not on a string.
Variables allow computers to store and manipulate data in a dynamic fashion. They do this by using a "label" to point to the data rather than using the data itself. Any of the seven data types may be stored in a variable.
Variables are similar to the x and y variables you use in mathematics, which means they're a simple name to represent the data we want to refer to. Computer variables differ from mathematical variables in that they can store different values at different times.
We tell JavaScript to create or declare a variable by putting the keyword var in front of it, like so:
var ourName ;
creates a variable called ourName. In JavaScript we end statements with semicolons. Variable names can be made up of numbers, letters, and $ or _, but may not contain spaces or start with a number.
Hints
When we store data in a data structure, we call it a variable. JavaScript variables are written in camel case. An example of camel case is: camelCase
You can declare a variable this way
var myName
= "Rafael";
ES6 introduced two other ways to declare variables. let and const. Let is pretty similar to var and for the most part is interchangeable:
let myAge
= 37;
Where let differs, is in its scope. When we declare using var, it’s global in scope. When we declare using let, the scope is limited to that function. If you want to use a let variable outside a function, you have to make it global in scope or redeclare it in the next function.
const, on the other hand, can only be declared once. Its value can never change.
const myName
= "Christina";