- Upper- or lowercase letter
- An underscore (_)
- A dollar sign ($)
After the first character, you can use any letter or number in your variable name, and it can be any length. JavaScript variables cannot contain spaces, mathematical operators, or punctuation (other than the underscore).
Always remember that JavaScript is case-sensitive. A variable named myname is not the same variable as Myname or myName.
Variable names are actually identifiers; the best thing you can do is to name a variable something precise and relevant. This naming convention may sometimes result in very long names, but as a rule, a longer name that accurately represents the variable is more useful than a shorter name that is vague.
No comments:
Post a Comment