Table of content:
- What is a variable?
- What are variable used for?
- Variables as Placeholders for Unknown Values
- Variables as Time-Savers
- Variables as Code Clarifiers
- How variables work in JavaScript
- JavaScript reserved words
- Variable types in JavaScript
- Number variables
- String variables
- Boolean variables
- Null variables
- Escaping characters
- Special characters in JavaScript
- How to use variables in scripts?
What is a variable?
A variable represents or hold a value.
Let’s consider the very commonly use example x=2. The name of the variable would be x and its value would be 2. The value of a variable can be changed at any given time simply by giving x a new assignment. For example x=4.
Consider the following math problem:
If x=2, then 3+x=?