From d94b4f47476bbc901753f68d6dfe317e1c5c732e Mon Sep 17 00:00:00 2001 From: MDN Date: Sat, 29 May 2021 01:14:43 +0000 Subject: [CRON] sync translated content --- .../operators/pipeline_operator/index.html | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 files/ja/orphaned/web/javascript/reference/operators/pipeline_operator/index.html (limited to 'files/ja/orphaned/web/javascript') diff --git a/files/ja/orphaned/web/javascript/reference/operators/pipeline_operator/index.html b/files/ja/orphaned/web/javascript/reference/operators/pipeline_operator/index.html new file mode 100644 index 0000000000..62a25f0673 --- /dev/null +++ b/files/ja/orphaned/web/javascript/reference/operators/pipeline_operator/index.html @@ -0,0 +1,88 @@ +--- +title: パイプライン演算子 (|>) +slug: orphaned/Web/JavaScript/Reference/Operators/Pipeline_operator +tags: + - Chaining + - Experimental + - JavaScript + - Language feature + - Operator + - Pipeline + - パイプライン + - 実験的 + - 演算子 + - 言語機能 + - 連結 +translation_of: Web/JavaScript/Reference/Operators/Pipeline_operator +original_slug: Web/JavaScript/Reference/Operators/Pipeline_operator +--- +
{{jsSidebar("Operators")}}
+ +

実験的なパイプライン演算子 |> (現在はステージ 1 です) は、式の値を関数に接続します。これによって、読みやすい方法で一連の関数呼び出しを作成することができます。結果的に、単一の引数を用いた関数呼び出しの糖衣構文となり、次のように書くことができます。

+ +
let url = "%21" |> decodeURI;
+ +

これと等価な従来の構文は次のようになります。

+ +
let url = decodeURI("%21");
+
+ +

構文

+ +
expression |> function
+
+ +

指定された expression の値が function に、単一の引数として渡されます。

+ +

引数

+ +
+
expression
+
任意の式です。
+
function
+
任意の関数です。
+
+ +

+ +

関数呼び出しの連結

+ +

パイプライン演算子は、複数の関数の連結を読みやすくすることができます。

+ +
const double = (n) => n * 2;
+const increment = (n) => n + 1;
+
+// パイプライン演算子なし
+double(increment(double(double(5)))); // 42
+
+// パイプライン演算子あり
+5 |> double |> double |> increment |> double; // 42
+
+ +

仕様

+ + + + + + + + + + + + +
仕様書
{{SpecName('Pipeline operator', '#sec-intro', 'Pipeline operator')}}
+ +

ブラウザー実装状況

+ + + +

{{Compat("javascript.operators.pipeline")}}

+ +

関連情報

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