# JavaScript Variables
● JavaScript Identifiers.
All JavaScript variables must be identified with unique names.These unique names are called identifiers.
Identifiers can be short names or more descriptive names.
The general rules for constructing names for variables are:
- Names can contain letters, digits, underscores, and dollar signs.
- Names must begin with a letter
- Names can also begin with $ and _ (but we will not use it in this tutorial)
- Names are case sensitive (y and Y are different variables)
- Reserved words (like JavaScript keywords) cannot be used as names
● JavaScript Data Types.
JavaScript variables can hold numbers like 100 & text values like "Kevin".
In Programming, text values are called text strings.
Javascript can handle many types of data.
Strings are written inside double or single quotes. Numbers are written without quotes.
Below image is the example of JSP Data Types.
● JavaScript Arithmetic
As with algebra, I can do arithmetic with JSP variables, using operators like = and +.
Also, I can add strings, but strings will be concatenated.
When I put a number in quotes, the rest of the number will be treated as strings,
and concatenated.
When I put a number in quotes, the rest of the number will be treated as strings,
and concatenated.
No comments:
Post a Comment