Relawan kami belum menerjemahkan artikel ini ke bahasa Bahasa Indonesia. Bergabunglah dan bantu kami menyelesaikannya!
Anda juga dapat membaca artikel ini dalam English (US).

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The experimental pipeline operator |> (currently at stage 1) allows the creation of chained function calls in a readable manner. Basically, the pipeline operator provides syntactic sugar on a function call with a single argument allowing you to write

'%21' |> decodeURI instead of decodeURI('%21').

Syntax

expression |> function

Examples

Chaining function calls

The pipeline operator can improve readability when chaining several functions.

const double = (n) => n * 2;
const increment = (n) => n + 1;

// without pipeline operator
double(increment(double(double(5)))); // 42

// with pipeline operator
5 |> double |> double |> increment |> double; // 42

Specifications

Specification Status Comment
Pipeline operator draft Stage 1 Not part of the ECMAScript specification yet.

Browser compatibility

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung InternetNode.js
Basic support
Experimental
Chrome No support NoEdge No support NoFirefox Full support 58
Disabled
Full support 58
Disabled
Disabled From version 58: this feature is behind the --enable-pipeline-operator compile flag.
IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android Full support 58
Disabled
Full support 58
Disabled
Disabled From version 58: this feature is behind the --enable-pipeline-operator compile flag.
Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No

Legend

Full support  
Full support
No support  
No support
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
User must explicitly enable this feature.
User must explicitly enable this feature.

See also

Tag Dokumen dan Kontributor

Kontributor untuk laman ini: sideshowbarker, charnz, cbalisky, DingoEatingFuzz, qwertypants, fscholz
Terakhir diperbarui oleh: sideshowbarker,