DEV Community

Fatima Alam
Fatima Alam

Posted on

Variable names in JS

Constants and global variables are always written in uppercase.

The following are the rules for naming variables in JavaScript:

  1. Spaces are not allowed in variable names.
  2. Only letters, digits, underscores, and dollar signs are permitted in variable names.
  3. Case matters when it comes to variable names.
  4. A letter (alphabet), an underscore (_), or a dollar sign ($) must be the first character in a variable name, any other special characters must not be taken.
  5. certain terms such as reserved words in javascript shouldn’t be used to name variables.

Top comments (0)