Backbencher.dev

Identifiers

An identifier is simple a name. In real world, we need names for people, things or countries to differentiate one from another. Similarly, we need names for following entities in JavaScript:

  • Constants
  • Variables
  • Properties
  • Functions
  • Classes
  • Labels

Rules for Identifier

In order to be a valid identifier, the identifier should meet following rules:

  1. The first letter of the identifier should be either an alphabet(A-Z, a-z), underscore(_) or dollar($).
  2. Subsequent characters can be alphabets, numbers, underscore and dollar.

Here are few examples of valid identifiers:

i
_
$
name
_age
$jQuery
a1234

Following identifiers are not valid:

2ndNumber
%value
Awesome!
Last updated on 24 Sep, 2022
Joby Joseph
Web Architect