Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2020面试总结 —— 函数式编程 #43

Open
fengmiaosen opened this issue Mar 22, 2020 · 0 comments
Open

2020面试总结 —— 函数式编程 #43

fengmiaosen opened this issue Mar 22, 2020 · 0 comments

Comments

@fengmiaosen
Copy link
Owner

  1. 函数式编程

    • 函数是第一等公民

      第一等公民是指函数跟其它的数据类型一样处于平等地位,可以赋值给其他变量,可以作为参数传入另一个函数,也可以作为别的函数的返回值

    • 函数是纯函数

      同输入同输出
      无副作用

    • 函数式编程具有两个最基本的运算:

      • 合成(compose)

        将代表各个动作的多个函数合并成一个函数

        function add4(x) {
            return x + 4
        }
        function multiply4(x) {
            return x * 4
        }
        
        console.log(multiply4(add4(1)))  // 20
        
        
      • 柯里化(Currying)

        接受一个单一参数
        返回接受余下的参数而且返回结果的新函数

    https://juejin.im/post/5b4ac0d0f265da0fa959a785

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant