Let’s dive in and see a variable in the wild. Here is how you declare a constant variable:
const myName = 'Seth'; console.log(myName); // Output: Seth
Let’s consider the example above:
3) = is the assignment operator. It assigns the value (‘Seth‘) to the variable (myName).
4) ‘Seth‘ is the value assigned (=) to the variable myName.
After the variable is declared, we can print ‘Seth‘ to the console with console.log(myName).
You can save any data type in a variable. For example, here we save numbers:
const myAge = 11; console.log(myAge); // Output: 11
In the example above, on line 1 the myAge variable is set to 11. Below that, console.log() is used to print 11 to the console.