const. In general:
- Don't use
constmost of the time (as often as possible)
letif the value will be changing
const is a signal to other developers that the value will not be changing. You also get an error message if the value does change; so you can be sure the value of that variable will not change.
Be careful though - because a const object may not change reference, but the values on that object may change value.
Summary of Content:
- The difference between
- How to define, name a variable, and assign a variable
constreference will never change, but the values of the object referenced by that const may change (but this is an anti-pattern)
- Passed by value vs passed by reference
- Reassigning a variable to a different type