Thanks to visit codestin.com
Credit goes to www.tutorialspoint.com

Variable Naming Conventions in JavaScript



While naming your variables in JavaScript, keep some rules in mind. The following are the variable naming conventions in JavaScript −

  • 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 

var name; // correct
var 2name; // incorrect
var _2name; // correct
Updated on: 2020-06-13T09:28:57+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements