JavaScript: Allowed Characters in Identifier
What is allowed characters in JavaScript identifiers?
JavaScript identifiers (variable/function names) must:
- Begin with a Unicode Letter, or low line _, dollar sign $.
- Following characters must be Unicode Letter or Unicode digit or low line or dollar sign.
Here is a example you can test:
// α GREEK SMALL LETTER ALPHA codepoint 945, hexadecimal 3b1 const α = 4; console.log(α); // ok
// ♥ BLACK HEART SUIT codepoint 9829, hexadecimal 2665 // is not a letter const ♥ = 3; // SyntaxError: Invalid or unexpected token
(To search for Unicode, or find a character's codepoint, see: Unicode Search 😄.)
What characters are Unicode Letter?
What Characters Are Unicode Letter