The type describes the kind of value
Strings represent text, numbers support arithmetic, booleans represent true or false, and null can intentionally mean no value. Arrays and objects organize several values into useful structures.
Names should explain the role
A variable such as itemCount communicates more than x. Use const when the binding will not be reassigned and let when the program intentionally changes which value the name refers to.
A familiar example
Representing a cart summary
- A number stores the item count.
- A string stores the visible currency label.
- A boolean records whether checkout is currently available.
What to remember
- Choose a data type that matches the value's meaning.
- Give variables names that explain their role.
- Use const by default and let for intentional reassignment.