From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../errors/identifier_after_number/index.html | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/errors/identifier_after_number/index.html (limited to 'files/zh-cn/web/javascript/reference/errors/identifier_after_number') diff --git a/files/zh-cn/web/javascript/reference/errors/identifier_after_number/index.html b/files/zh-cn/web/javascript/reference/errors/identifier_after_number/index.html new file mode 100644 index 0000000000..c2607edd2b --- /dev/null +++ b/files/zh-cn/web/javascript/reference/errors/identifier_after_number/index.html @@ -0,0 +1,48 @@ +--- +title: 'SyntaxError: identifier starts immediately after numeric literal' +slug: Web/JavaScript/Reference/Errors/Identifier_after_number +translation_of: Web/JavaScript/Reference/Errors/Identifier_after_number +--- +
{{JSSidebar("Errors")}}
+ +

Message

+ +
SyntaxError: identifier starts immediately after numeric literal (Firefox)
+SyntaxError: Unexpected number (Chrome)
+
+ +

Error type

+ +

{{jsxref("SyntaxError")}}

+ +

What went wrong?

+ +

变量名叫{{Glossary("Identifier", "identifiers")}},它符合某些规则,而你打破了这些规则!

+ +

一个JavaScript标识符必须以字母开头,下划线(_)或美元符号($)。他们不能以数字开头。只有后续字符可以是数字(0-9)。

+ +

Examples

+ +

Variable names starting with numeric literals

+ +

Variable names can't start with numbers in JavaScript. The following fails:

+ +
var 1life = 'foo';
+// SyntaxError: identifier starts immediately after numeric literal
+
+var foo = 1life;
+// SyntaxError: identifier starts immediately after numeric literal
+
+ +

You will need to rename your variable to avoid the leading number.

+ +
var life1 = 'foo';
+var foo = life1;
+
+ +

See also

+ + -- cgit v1.2.3-54-g00ecf