The JavaScript exception "identifier starts immediately after numeric literal" occurs when an identifier started with a digit. Identifiers can only start with a letter, underscore (_), or dollar sign ($).
The JavaScript exception "identifier starts immediately after numeric literal" occurs when an identifier started with a digit. Identifiers can only start with a letter, underscore (_), or dollar sign ($).
SyntaxError: Unexpected identifier after numeric literal (Edge) SyntaxError: identifier starts immediately after numeric literal (Firefox) SyntaxError: Unexpected number (Chrome)
The names of variables, called identifiers, conform to certain rules, which your code must adhere to!
A JavaScript identifier must start with a letter, underscore (_), or dollar sign ($). They can't start with a digit! Only subsequent characters can be digits (0-9).
Variable names can't start with numbers in JavaScript. The following fails:
const 1life = "foo"; // SyntaxError: identifier starts immediately after numeric literal const foo = 1life; // SyntaxError: identifier starts immediately after numeric literal alert(1.foo); // SyntaxError: identifier starts immediately after numeric literal
You will need to rename your variable to avoid the leading number.
const life1 = "foo"; const foo = life1;
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Identifier_after_number