From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../global_objects/symbol/split/index.html | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 files/ja/web/javascript/reference/global_objects/symbol/split/index.html (limited to 'files/ja/web/javascript/reference/global_objects/symbol/split/index.html') diff --git a/files/ja/web/javascript/reference/global_objects/symbol/split/index.html b/files/ja/web/javascript/reference/global_objects/symbol/split/index.html new file mode 100644 index 0000000000..838b757727 --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/symbol/split/index.html @@ -0,0 +1,65 @@ +--- +title: Symbol.split +slug: Web/JavaScript/Reference/Global_Objects/Symbol/split +tags: + - ECMAScript 2015 + - JavaScript + - Property + - Symbol +translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/split +--- +
{{JSRef}}
+ +

Symbol.split ウェルノウンシンボルは、正規表現に一致する位置で文字列を分割するメソッドを指定します。この関数は {{jsxref("String.prototype.split()")}} メソッドによって呼び出されます。

+ +

詳しくは、 {{jsxref("RegExp.@@split", "RegExp.prototype[@@split]()")}} と {{jsxref("String.prototype.split()")}} を参照してください。

+ +
{{EmbedInteractiveExample("pages/js/symbol-split.html")}}
+ + + +
{{js_property_attributes(0,0,0)}}
+ +

+ +

独自の逆方向の分割

+ +
class ReverseSplit {
+  [Symbol.split](string) {
+    const array = string.split(' ');
+    return array.reverse();
+  }
+}
+
+console.log('Another one bites the dust'.split(new ReverseSplit()));
+// expected output: [ "dust", "the", "bites", "one", "Another" ]
+ +

仕様書

+ + + + + + + + + + + + +
仕様書
{{SpecName('ESDraft', '#sec-symbol.split', 'Symbol.split')}}
+ +

ブラウザーの互換性

+ + + +

{{Compat("javascript.builtins.Symbol.split")}}

+ +

関連情報

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