
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to name variables in JavaScript?
Variables can be thought of as named containers. You can place data into these containers and then refer to the data simply by naming the container.
While naming your variables in JavaScript, keep the following rules in mind.
- You should not use any of the JavaScript reserved keywords as a variable name. These keywords are mentioned in the next section. For example, break or boolean variable names are not valid.
- JavaScript variable names should not start with a numeral (0-9). They must begin with a letter or an underscore character. For example, 123test is an invalid variable name but _123test is a valid one.
- JavaScript variable names are case-sensitive. For example, Name and name are two different variables.
Here are the Examples −
<script> var rank; var points; </script>
- Related Articles
- How to declare variables in JavaScript?
- How to declare global Variables in JavaScript?
- How to declare String Variables in JavaScript?
- How to declare boolean variables in JavaScript?
- How to use Global Variables in JavaScript?
- How to use Static Variables in JavaScript?
- How to swap two variables in JavaScript?
- How to pass JavaScript variables to PHP?
- How to use JavaScript variables in jQuery selectors?
- How to concatenate multiple string variables in JavaScript?
- How to swap variables with destructuring in JavaScript?
- How to declare Block-Scoped Variables in JavaScript?
- How to prevent duplicate JavaScript Variables Declaration?
- How and why to avoid global variables in JavaScript?
- How to disallow altering of object variables in JavaScript?

Advertisements