aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/javascript/reference/global_objects/regexp/@@species/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/ja/web/javascript/reference/global_objects/regexp/@@species/index.html')
-rw-r--r--files/ja/web/javascript/reference/global_objects/regexp/@@species/index.html70
1 files changed, 70 insertions, 0 deletions
diff --git a/files/ja/web/javascript/reference/global_objects/regexp/@@species/index.html b/files/ja/web/javascript/reference/global_objects/regexp/@@species/index.html
new file mode 100644
index 0000000000..440ca4aeec
--- /dev/null
+++ b/files/ja/web/javascript/reference/global_objects/regexp/@@species/index.html
@@ -0,0 +1,70 @@
+---
+title: 'get RegExp[@@species]'
+slug: Web/JavaScript/Reference/Global_Objects/RegExp/@@species
+tags:
+ - JavaScript
+ - Property
+ - Prototype
+ - Reference
+ - RegExp
+ - Regular Expressions
+translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/@@species
+---
+<div>{{JSRef}}</div>
+
+<p><strong><code>RegExp[@@species]</code></strong> アクセサープロパティは <code>RegExp</code> コンストラクターを返します。</p>
+
+<div>{{EmbedInteractiveExample("pages/js/regexp-getregexp-@@species.html")}}</div>
+
+<div class="hidden">このデモのソースファイルは GitHub リポジトリに格納されています。デモプロジェクトに協力したい場合は、 <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> をクローンしてプルリクエストを送信してください。</div>
+
+<h2 id="Description" name="Description">解説</h2>
+
+<p><code>species</code> アクセサープロパティは、 <code>RegExp</code> の既定のコンストラクターを返します。サブクラスのコンストラクターは、コンストラクターの割り当てをオーバーライドするためにこれを使用することができます。</p>
+
+<h2 id="Examples" name="Examples">例</h2>
+
+<h3 id="Species_in_ordinary_objects" name="Species_in_ordinary_objects">通常オブジェクトの species</h3>
+
+<p><code>species</code> プロパティは、既定のコンストラクターを返します。 <code>RegExp</code> オブジェクトであれば、 <code>RegExp</code> コンストラクターを返します。</p>
+
+<pre class="brush: js notranslate">RegExp[Symbol.species]; // function RegExp()</pre>
+
+<h3 id="Species_in_derived_objects" name="Species_in_derived_objects">派生オブジェクトの species</h3>
+
+<p>派生クラスのコレクションオブジェクト (たとえば、独自の正規表現を表す <code>MyRegExp</code>) では、 <code>MyRegExp</code> の species は <code>MyRegExp</code> コンストラクターです。しかし、派生クラスのメソッドで親である <code>RegExp</code> オブジェクトを返すようにこれをオーバーライドしたくなるかもしれません。</p>
+
+<pre class="brush: js notranslate">class MyRegExp extends RegExp {
+ // MyRegExp の species を親である RegExp コンストラクタにオーバーライドします。
+ static get [Symbol.species]() { return RegExp; }
+}</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-regexp-@@species', 'get RegExp [ @@species ]')}}</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.RegExp.@@species")}}</p>
+</div>
+
+<h2 id="See_also" name="See_also">関連情報</h2>
+
+<ul>
+ <li>{{jsxref("RegExp")}}</li>
+ <li>{{jsxref("Symbol.species")}}</li>
+</ul>