A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.cdn.mozilla.net/ja/docs/Web/JavaScript/Reference/Errors/Identifier_after_number below:

SyntaxError: identifier starts immediately after numeric literal - JavaScript

SyntaxError: identifier starts immediately after numeric literal

JavaScript の例外 "identifier starts immediately after numeric literal" は、識別子が数字で始まっているときに発生します。識別子の先頭は英字、アンダースコア (_)、ドル記号 ($) しか使うことができません。

エラーメッセージ
SyntaxError: Unexpected identifier after numeric literal (Edge)
SyntaxError: identifier starts immediately after numeric literal (Firefox)
SyntaxError: Unexpected number (Chrome)
エラータイプ 何がうまくいかなかったのか?

変数の名前、いわゆる識別子は特定のルールに従う必要があり、それに反しています。

JavaScript の識別子は文字かアンダースコア (_)、ドル記号 ($) で始まる必要があります。数値からは始められません。 2 文字目以降でのみ、数値 (0-9) を使用することができます。

例 数字から始まる変数名

JavaScript は変数名を数字から始めることはできません。次の例は失敗します。

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

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

alert(1.foo);
// SyntaxError: identifier starts immediately after numeric literal

数値始まりにならないように、変数名を変更する必要があります。

var life1 = "foo";
var foo = life1;
関連項目

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4