QamoosTech
Programming FundamentalsLanguage basicsBeginner

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 undefined because 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 chatLet us store this API response in a new variable before we process the data.
  • In an email or ticketPlease make sure to rename this variable to something more descriptive before merging the pull request.