Declaring a variable can be done using the traditional var keyword, which has some gotchas. A variable declared using var becomes available not only inside the block in which it's defined, but also outside the block scope in the containing module, namespace, or global scope. This can lead to programming errors that are hard to catch. A better way to declare variable types is by using the two relatively new keywords like let and const. These are used similar to the var keyword, but the outcome is very different. Using let is the same as using block-scope, and unlike var these variables aren't leaked outside their containing blocks. The keyword const just augments let and prevents any reassignment to its variables.
When declaring a variable, the variable name is followed by a colon and then its type. It may also contain an optional...