General rules for naming variables
What is a variable
It is a container for a value.
- It holds reusable data in a program and associates it with a name
var
a key word that declares new variable var myName = 'Bethani'; console.log(myName); // Output: Bethani
In this case, key word variable is being used.
Where are variables stored
In memory
Preferred variable keywords
let is the preferred way to declare a variable for reassigning and const when you want it to remain constant
When variables have not been initialized
they store the primitive data type undefined.
Mathematical assignment operators and variables
make it easy to calculate a new value and assign it to the same variable
+ operator used for what in variables
used to concatenate strings held in variables
Since ES6 what are backticks ` and ${} used for
` backticks
${} placeholder
- used to interpolate values into a string.
typeof keyword
returns the data type (as a string) of a value