Identifier and Variable Names

This article describes best practices when using identifiers. Identifiers are "names" that identify variables, constants, properties, and other elements in a JavaScript program. For example, when creating a variable in a program to store your age, you might give it the identifier "age".

Here are some things to remember when using identifiers:

  • JavaScript is case-sensitive, and you must use consistent spelling;
  • identifiers cannot start with a digit; 
  • identifiers cannot have spaces in the name; and
  • use meaningful names.

Key Terms

camel case
The practice of writing compound words or phrases such that each word or abbreviation in the middle of the phrase begins with a capital letter, with no intervening spaces or punctuation.
Pascal case
The practice of writing compound words or phrases such that each word or abbreviation in the phrase begins with a capital letter, including the first letter, with no intervening spaces or punctuation.
reserved word
Words that cannot be used by the programmer as identifier names because they already have a specific meaning within the programming language.
snake case
The practice of writing compound words or phrases in which the elements are separated with one underscore character (_) and no spaces, with each element's initial letter usually lowercased within the compound and the first letter either upper or lower case.