diff options
Diffstat (limited to 'files/ja/web/javascript/reference/global_objects/array/@@unscopables/index.html')
| -rw-r--r-- | files/ja/web/javascript/reference/global_objects/array/@@unscopables/index.html | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/files/ja/web/javascript/reference/global_objects/array/@@unscopables/index.html b/files/ja/web/javascript/reference/global_objects/array/@@unscopables/index.html new file mode 100644 index 0000000000..478ccbfb0e --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/array/@@unscopables/index.html @@ -0,0 +1,78 @@ +--- +title: 'Array.prototype[@@unscopables]' +slug: Web/JavaScript/Reference/Global_Objects/Array/@@unscopables +tags: + - Array + - ECMAScript 2015 + - JavaScript + - Property + - Prototype +translation_of: Web/JavaScript/Reference/Global_Objects/Array/@@unscopables +--- +<div>{{JSRef}}</div> + +<p><code><strong>@@unscopable</strong></code> シンボルプロパティには、 ES2015 以前の ECMAScript 標準には含まれていないプロパティ名があります。それらのプロパティは、<code><a href="/ja/docs/Web/JavaScript/Reference/Statements/with">with</a></code> 文のバインディングから除外されます。</p> + +<h2 id="Description" name="Description">解説</h2> + +<p><code>with</code> バインディングから除外される既定の配列プロパティは次のとおりです。</p> + +<ul> + <li>{{jsxref("Array.prototype.copyWithin()", "copyWithin()")}}</li> + <li>{{jsxref("Array.prototype.entries()", "entries()")}}</li> + <li>{{jsxref("Array.prototype.fill()", "fill()")}}</li> + <li>{{jsxref("Array.prototype.find()", "find()")}}</li> + <li>{{jsxref("Array.prototype.findIndex()", "findIndex()")}}</li> + <li>{{jsxref("Array.prototype.includes()", "includes()")}}</li> + <li>{{jsxref("Array.prototype.keys()", "keys()")}}</li> + <li>{{jsxref("Array.prototype.values()", "values()")}}</li> +</ul> + +<p>自作オブジェクトに <code>unscopables</code> を設定する方法については、 {{jsxref("Symbol.unscopables")}} を見てください。</p> + +<p>{{js_property_attributes(0,0,1)}}</p> + +<h2 id="Examples" name="Examples">例</h2> + +<h3 id="Use_in_with_environments" name="Use_in_with_environments">with 環境内での使用</h3> + +<p>次のコードは、 ES5 以下であれば正常に動作します。しかし、 ECMAScript 2015 以降では {{jsxref("Array.prototype.keys()")}} メソッドが導入されました。つまり、<code>with</code> 環境内では、 "keys" はメソッドであり、変数ではありません。ここが組込み <code>@@unscopables</code> の役立つ場所です。<code>Array.prototype[@@unscopables]</code> シンボルプロパティが使用されると、配列のいくつかのメソッドが <code>with</code> 文のスコープに入ることを防ぎます。</p> + +<pre class="brush: js notranslate">var keys = []; + +with (Array.prototype) { + keys.push('something'); +} + +Object.keys(Array.prototype[Symbol.unscopables]); +// ["copyWithin", "entries", "fill", "find", "findIndex", +// "includes", "keys", "values"]</pre> + +<h2 id="Specifications" name="Specifications">仕様書</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('ESDraft', '#sec-array.prototype-@@unscopables', 'Array.prototype[@@unscopables]')}}</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2> + +<div> +<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div> + +<p>{{Compat("javascript.builtins.Array.@@unscopables")}}</p> +</div> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{jsxref("Symbol.unscopables")}}</li> +</ul> |
