๐Ÿ”
๐Ÿ‘ถ Kids๐Ÿ“ Blog About Contact ๐Ÿš€ Get Started Free

JS Variables

JavaScript variables are containers for storing data values.

Variables are named containers that store values you can reuse throughout your program. JavaScript gives you three keywords to declare them.

KeywordReassignableScopeUse When
constโŒ NoBlockValue wonโ€™t change (recommended default)
letโœ… YesBlockValue will change
varโœ… YesFunctionOld code โ€” avoid in modern JS

Try It โ€” Variables in Action

Preview

Variable Naming Rules

  • Must start with a letter, $, or _
  • Can contain letters, digits, $, _
  • Case sensitive โ€” name โ‰  Name
  • Cannot be a reserved keyword (let, if, return, etc.)

Tip: Good variable names describe what the value means: userName, totalPrice, isLoggedIn. Avoid single letters like x or vague names like data.