` Symbol Mean in JavaScript? " />
What Does this Symbol Mean in JavaScript?
## (| >) Pipe, Greater Than: Pipeline Operator
Description:
The |> operator, introduced in ECMAScript 2021, is the pipeline operator. It allows you to connect multiple expressions and evaluate them sequentially, passing the result of one expression as the input to the next.
Example:
const result = [1, 2, 3] .map(n => n * 2) // Double each number .filter(n => n > 4) // Filter numbers greater than 4 .reduce((a, b) => a + b, 0); // Sum the filtered numbers, starting from 0
Note: The pipeline operator is a syntactic sugar for composing functions. It is equivalent to the following code:
const mapResult = [1, 2, 3].map(n => n * 2); const filterResult = mapResult.filter(n => n > 4); const reduceResult = filterResult.reduce((a, b) => a + b, 0);
The above is the detailed content of What Does the `|>` Symbol Mean in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!