Today I learned....
let message = Hello;
var is an old school way of declaring a variable. This declaration exists in older scripts. Declaring a variable twice will trigger an error.
There are two variable naming limitations:
- The name must contain only letters, digits, or the symbols $ and _.
- The first character must not be a digit.
camelCase is commonly used naming convention, for example, newToy.
Constants is an unchanging variable meaning the value cannot be reassigned. The keyword to use is const. When declaring a variables, its a general rule to use const unless you know the value will change. I'm guessing this is to prevent any accidental reassignment of a value.
It is a common practice to use constants as aliases for difficult-to-remember values that are known prior to execution.
They are named using capital letters and underscores.
A capitol constant name is used when the value is known prior and is hard-coded in.
A lower case constant is calculated run time and doesn't change after initial assignment.
const does define a constant value, but a read-only reference to a value. For this reason, the value cannot be reassigned or redeclared, but you can change the elements of constant array and change the properties of constant object
Day 20: https://dev.to/jennifer_tieu/self-taught-developer-journal-day-20-top-landing-page-cont-the-fourth-section-and-footer-57b
Please refer to Starting My Self-Taught Developer Journey for context.