aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/javascript/reference/global_objects/map/@@species/index.html
blob: 1bcaf853e6a7552eb8a6ae1a5637f9711be0e9c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
title: get Map[@@species]
slug: Web/JavaScript/Reference/Global_Objects/Map/@@species
tags:
  - ECMAScript 2015
  - JavaScript
  - Map
  - Property
translation_of: Web/JavaScript/Reference/Global_Objects/Map/@@species
---
<div>{{JSRef}}</div>

<p><strong><code>Map[@@species]</code></strong> アクセサープロパティは、 <code>Map</code> コンストラクターを返します。</p>

<h2 id="Description" name="Description">解説</h2>

<p>species アクセサープロパティは <code>Map</code> オブジェクトのデフォルトコンストラクターを返します。サブクラスのコンストラクターは、コンストラクターに代入して変更することによりオーバーライドすることができます。</p>

<h2 id="Examples" name="Examples"></h2>

<h3 id="Species_in_ordinary_objects" name="Species_in_ordinary_objects">通常のオブジェクトの species</h3>

<p>species プロパティはデフォルトコンストラクター関数を返しますので、 <code>Map</code> オブジェクトには <code>Map</code> コンストラクターを返します。</p>

<pre class="brush: js notranslate">Map[Symbol.species]; // function Map()</pre>

<h3 id="Species_in_derived_objects" name="Species_in_derived_objects">派生オブジェクトの species</h3>

<p>派生したコレクションオブジェクトの中では (例えばカスタムマップである <code>MyMap</code>)、 <code>MyMap</code> の species は <code>MyMap</code> コンストラクターになっています。しかし、これをオーバーライドして、派生クラスのメソッド内で親の <code>Map</code> オブジェクトを返したい場合があります。</p>

<pre class="brush: js notranslate">class MyMap extends Map {
  // Overwrite MyMap species to the parent Map constructor
  static get [Symbol.species]() { return Map; }
}</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-get-map-@@species', 'get Map [ @@species ]')}}</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>

<div>
<p>{{Compat("javascript.builtins.Map.@@species")}}</p>
</div>

<h2 id="See_also" name="See_also">関連情報</h2>

<ul>
 <li>{{jsxref("Map")}}</li>
 <li>{{jsxref("Symbol.species")}}</li>
</ul>