From fa9d0b4ad49db970ba8707a4f6ab9ce17b5383b8 Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Fri, 25 Jun 2021 01:40:44 +0900 Subject: Web/JavaScript/Reference/Errors/P-V* を更新 (#1205) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Web/JavaScript/Reference/Errors/P-V* を更新 2021/06/14 時点の英語版に同期 * スラッグを修正 --- .../reference/errors/undefined_prop/index.html | 118 ++++++++++----------- 1 file changed, 59 insertions(+), 59 deletions(-) (limited to 'files/ja/web/javascript/reference/errors/undefined_prop') diff --git a/files/ja/web/javascript/reference/errors/undefined_prop/index.html b/files/ja/web/javascript/reference/errors/undefined_prop/index.html index cb2ec02f1a..fa5c1e8067 100644 --- a/files/ja/web/javascript/reference/errors/undefined_prop/index.html +++ b/files/ja/web/javascript/reference/errors/undefined_prop/index.html @@ -1,59 +1,59 @@ ---- -title: 'ReferenceError: reference to undefined property "x"' -slug: Web/JavaScript/Reference/Errors/Undefined_prop -tags: - - Errors - - JavaScript - - ReferenceError - - Strict Mode -translation_of: Web/JavaScript/Reference/Errors/Undefined_prop ---- -
{{jsSidebar("Errors")}}
- -

メッセージ

- -
ReferenceError: reference to undefined property "x" (Firefox)
-
- -

エラータイプ

- -

strict モード でのみ、{{jsxref("ReferenceError")}} の警告が出ます。

- -

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

- -

存在しないオブジェクトのプロパティにアクセスしようとしています。プロパティにアクセスする方法は 2 つあります。詳細については、メンバー演算子参照ページを見てください。

- -

未定義プロパティを参照することによるエラーは、strict モードのコードでのみ発生します。非 strict コードでは、暗黙的に無視されます。

- -

- -

無効なケース

- -

このケースでは、"bar" は未定義のプロパティです。

- -
"use strict";
-
-var foo = {};
-foo.bar; // ReferenceError: reference to undefined property "bar"
-
- -

有効なケース

- -

エラーを避けるには、"bar" プロパティを定義するか、使用する前に "bar" プロパティが存在するか確認する必要があります(たとえば、{{jsxref("Object.prototype.hasOwnProperty()")}} メソッドを使用します)。

- -
"use strict";
-
-var foo = {};
-
-foo.bar = "moon";
-console.log(foo.bar); // "moon"
-
-if (foo.hasOwnProperty("bar") {
-  console.log(foo.bar);
-}
- -

関連項目

- - +--- +title: 'ReferenceError: reference to undefined property "x"' +slug: Web/JavaScript/Reference/Errors/Undefined_prop +tags: + - Errors + - JavaScript + - ReferenceError + - Strict Mode +translation_of: Web/JavaScript/Reference/Errors/Undefined_prop +--- +
{{jsSidebar("Errors")}}
+ +

メッセージ

+ +
ReferenceError: reference to undefined property "x" (Firefox)
+
+ +

エラーの種類

+ +

strict モード でのみ、{{jsxref("ReferenceError")}} の警告が出ます。

+ +

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

+ +

存在しないオブジェクトのプロパティにアクセスしようとしています。プロパティにアクセスする方法は 2 つあります。詳細については、メンバー演算子参照ページを見てください。

+ +

未定義プロパティを参照することによるエラーは、strict モードのコードでのみ発生します。非 strict コードでは、暗黙的に無視されます。

+ +

+ +

無効なケース

+ +

このケースでは、"bar" は未定義のプロパティです。

+ +
"use strict";
+
+var foo = {};
+foo.bar; // ReferenceError: reference to undefined property "bar"
+
+ +

有効なケース

+ +

エラーを避けるには、"bar" プロパティを定義するか、使用する前に "bar" プロパティが存在するか確認する必要があります(たとえば、{{jsxref("Object.prototype.hasOwnProperty()")}} メソッドを使用します)。

+ +
"use strict";
+
+var foo = {};
+
+foo.bar = "moon";
+console.log(foo.bar); // "moon"
+
+if (foo.hasOwnProperty("bar") {
+  console.log(foo.bar);
+}
+ +

関連項目

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