creating a variable
var is short for variable and is a pre-ES6 way of declaring a variable. ES6 keyword to declare a variable are const and let. Nevertheless, it is good to familiarize ourselves with pre-ES6 because tons of codes were written using var.
var 8 =”twitter”. // variable name cannot start with numbers
var can be re-declared or updated.
var favoriteColor =”red”
var favoriteColor =”yellow” //re-declare
var favoriteColor; // not assigned a value. In this case the variable will automatically be given a value of undefined
The reason var was let go and const and let was introduced is because var will likely cause a lot of bugs in the code. Again, familiarize yourself with it and stay tuned for more.