zoukankan      html  css  js  c++  java
  • xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

    ES2021 & Pipeline operator (|>) / 管道运算符 |>

    demo

    
    "use strict";
    
    /**
     *
     * @author xgqfrms
     * @license MIT
     * @copyright xgqfrms
     * @created 2020-08-01
     * @modified
     *
     * @description Pipeline operator (|>) / 管道运算符 |>
     * @difficulty Easy Medium Hard
     * @complexity O(n)
     * @augments
     * @example
     * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Pipeline_operator
     * @solutions
     *
     */
    
    const log = console.log;
    
    /*
    
    expression |> function
    
    // 实验性管道运算符|>(当前处于阶段1)将表达式的值通过管道传递给函数。
    
    */
    
    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
    
    
    

    refs

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Pipeline_operator


    Flag Counter

    ©xgqfrms 2012-2020

    www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


  • 相关阅读:
    火柴排队sol
    国王游戏sol
    子串sol
    跳石头
    解方程sol
    花匠sol
    字符串整理
    计算系数
    矩阵取数游戏sol
    8.2_java_28
  • 原文地址:https://www.cnblogs.com/xgqfrms/p/13415794.html
Copyright © 2011-2022 走看看