Pure functions and higher-order functions
開発
2023-04-09 01:04:34
訪問数: null
pure function
- As long as it is the same input (actual parameter), the same output (return) must be obtained
- Do not overwrite parameter data
- Does not produce any side effects such as network requests, input and output devices
- Cannot call
Data.now()
or Math.random()
wait for impure methods
- Redux
reducer
functions must be pure functions
higher order functions
参数是函数
or 返回是参数
a function of
- Common high-order functions: timer setting functions, arrays
forEach()/map()/filter()/find()/bind()
, Promise, etc.
転載: blog.csdn.net/Dax1_/article/details/126592135