From d3798b74c2e8aaad6ba1c89d96311996572d1dcc Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Tue, 8 Jun 2021 00:01:43 +0900 Subject: Errors/Cant_access_lexical_declaration_before_init を更新 (#1141) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2021/03/29 時点の英語版に同期 --- .../index.html | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'files') diff --git a/files/ja/web/javascript/reference/errors/cant_access_lexical_declaration_before_init/index.html b/files/ja/web/javascript/reference/errors/cant_access_lexical_declaration_before_init/index.html index b6c629ee38..4fc4168afb 100644 --- a/files/ja/web/javascript/reference/errors/cant_access_lexical_declaration_before_init/index.html +++ b/files/ja/web/javascript/reference/errors/cant_access_lexical_declaration_before_init/index.html @@ -2,30 +2,35 @@ title: 'ReferenceError: can''t access lexical declaration`X'' before initialization' slug: Web/JavaScript/Reference/Errors/Cant_access_lexical_declaration_before_init tags: + - Error - Errors - JavaScript - - ReferemceError + - ReferenceError translation_of: Web/JavaScript/Reference/Errors/Cant_access_lexical_declaration_before_init ---
{{jsSidebar("Errors")}}
-

メッセージ

+

JavaScript の例外 "can't access lexical declaration `variable' before + initialization" は、語彙変数が初期化前にアクセスされたときに発生します。これはブロック文内で、 let または const 宣言が定義される前にアクセスされたときに発生します。

-
ReferenceError: can't access lexical declaration `X' before initialization (Firefox)
+

エラーメッセージ

+ +
ReferenceError: Use before delaration (Edge)
+ReferenceError: can't access lexical declaration `X' before initialization (Firefox)
 ReferenceError: 'x' is not defined (Chrome)
 
-

エラータイプ

+

エラーの種類

{{jsxref("ReferenceError")}}

-

何がうまくいかなかったのか?

+

エラーの原因

初期化前に語彙変数にアクセスしました。これはブロックステートメント内で、定義される前にletconst 宣言にアクセスすると発生します。

-

+

-

不正な場合

+

不正な場合

この場合、変数 "foo" はブロックステートメント内で let を使用して再宣言されています。

@@ -40,7 +45,7 @@ ReferenceError: 'x' is not defined (Chrome) test();
-

有効な場合

+

有効な場合

"foo" を if ステートメント内に変更するには、再宣言の原因となる let を取り除きます。

@@ -53,8 +58,8 @@ test(); test(); -

関連項目

+

関連情報

-- cgit v1.2.3-54-g00ecf