Variable
PronunciationVAIR-ee-uh-bul
Definition
A named place in memory that stores a value. The program reads the value through its name and can change it later, which is why code uses the name rather than the value itself.
Where you hear it
In every programming tutorial, code review, and bug report.
Examples
Store the user's age in a variable called
age.The variable is
undefinedbecause it was never assigned.The variable total starts at zero and grows as each item is added.
Common mistake
Choosing vague names like x or data. A good variable name says what it holds, e.g. invoiceTotal.
Don't confuse with
A variable stores a single value that can change, whereas a constant holds a value that cannot be reassigned after its initial definition.
Say it at work
- In a meeting or chat
Let us store this API response in a new variable before we process the data.
- In an email or ticket
Please make sure to rename this variable to something more descriptive before merging the pull request.
Keep exploring
More in Programming Fundamentals