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

第三十二题:什么是高阶函数? #32

Open
Ray-56 opened this issue Sep 24, 2019 · 1 comment
Open

第三十二题:什么是高阶函数? #32

Ray-56 opened this issue Sep 24, 2019 · 1 comment
Labels
JavaScript 解释型编程语言

Comments

@Ray-56
Copy link
Owner

Ray-56 commented Sep 24, 2019

什么是高阶函数?

@Ray-56 Ray-56 added the JavaScript 解释型编程语言 label Sep 24, 2019
@MMmaXingXing
Copy link

高阶函数(Higher-order function)

高阶函数就是参数为函数或者返回值为函数的函数。有了高阶函数,就可以将复用的粒度降低到函数级别,相对于面向对象语言,服复用的粒度更低。

高阶函数提供了一种函数级别上的依赖注入(或反转控制机制)。比如我们现在常用的Math.cell(),这就是实际应用中已经封装好的高阶函数。很多GOF设计模式都可以使用高阶函数实现,如Visitor,Strategy,Decorator等,如Visitor就可以用高阶函数中的map()或forEach()高阶函数来替代。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JavaScript 解释型编程语言
Projects
None yet
Development

No branches or pull requests

2 participants