本文共 1674 字,大约阅读时间需要 5 分钟。
bug探索
was named one of the !
被评为 !
In JavaScript, functions are first-class objects, which means they can be:
在JavaScript中,函数是一流的对象,这意味着它们可以是:
Functions can be stored in three ways:
函数可以通过三种方式存储:
store in a variable : let fn = function doSomething() {}
存储在变量中: let fn = function doSomething() {}
store in an object : let obj = { doSomething : function(){} }
存储在一个对象中: let obj = { doSomething : function(){} }
store in an array : arr.push(function doSomething() {})
存储在数组中: arr.push(function doSomething() {})
In the first and third example, I used a named function expression.
在第一个和第三个示例中,我使用了一个命名函数表达式。
The function expression defines a function as part of a larger expression. The line of code doesn’t start with function
.
函数表达式将函数定义为较大表达式的一部分。 代码行不是以function
开头的。
In the next example, the function doSomething
is sent as an argument to doAction()
.
在下一个示例中,函数doSomething
作为参数发送给doAction()
。
doAction(function doSomething(){});
doSomething
is a callback.
doSomething
是一个回调。
A callback is a function passed as an argument to another function.
回调是作为参数传递给另一个函数的函数。
A higher order function is a function that takes another function as an input, returns a function or does both.
高阶函数是将另一个函数作为输入,返回一个函数或同时执行两个函数的函数。
You can find more in the book.
您可以在“ 一书中找到更多信息。
For more on applying functional programming techniques in React take a look at .
有关在React中应用函数式编程技术的更多信息,请查看 。
Learn functional React, in a project-based way, with .
通过 ,以基于项目的方式学习功能性React 。
翻译自:
bug探索
转载地址:http://kcwzd.baihongyu.com/