![]() |
![]() ![]() |
2.7 IdentifiersAn identifier is simply a name. In JavaScript, identifiers are used to name variables and functions and to provide labels for certain loops in JavaScript code. The rules for legal identifier names are the same in JavaScript as they are in Java and many other languages. The first character must be a letter, an underscore (_), or a dollar sign ($).[1] Subsequent characters may be any letter or digit or an underscore or dollar sign. (Numbers are not allowed as the first character so that JavaScript can easily distinguish identifiers from numbers.) These are all legal identifiers:
i my_variable_name v13 _dummy $str In ECMAScript v3, identifiers can
contain letters and digits from the complete Unicode character set.
Prior to this version of the standard, JavaScript identifiers are
restricted to the ASCII character set. ECMAScript v3 also allows
Unicode escape sequences to appear in identifiers. A Unicode escape
is the characters \u followed by 4 hexadecimal
digits that specify a 16-bit character encoding. For example, the
identifier Finally, identifiers cannot be the same as any of the keywords used for other purposes in JavaScript. The next section lists the special names that are reserved in JavaScript. |
![]() |
![]() ![]() |