-
Let & Const vs var
-
Arrow functions and default arguements
-
Template strings & string improvements
-
Destructuring
-
Interables & Loops
-
Array Improvements
-
Spread & Rest
-
Promises
-
JS modules & NPM
-
Object Orientated JS
var dogYears = age * 7;
Looking at the above var what do you see ? you see a variable you can call anywhwere which can cause problems when you want to just call something once or are using a temporary variable.
It is best to put vars inside a function (since you are controlling it's scope)but they must be WITHIN the function for it to play well.
const dogYears1 = age * 7;
The const declaration creates a read-only variable - this does not mean the value is immutable (it isn't unless we use object.freeze) what it DOES mean is that the variable cannot be reassigned so its parameters can be altered but what it is itself cannot be changed (i.e we cannot change the variables name to catLives but we can change it to be 9)
LET AND CONST ARE BLOCK SCOPED