Last active
March 9, 2018 05:20
-
-
Save Gyumeijie/da6248f36ee4798021d3498fc5bc6d80 to your computer and use it in GitHub Desktop.
usage of some important javascript functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Array.reduce | |
有初始值: | |
If an initialValue was provided in the call to reduce, then previousValue will be equal to initialValue | |
and currentValue will be equal to the first value in the array. | |
没有初始值: | |
If no initialValue was provided, then previousValue will be equal to the first value in the array | |
and currentValue will be equal to the second | |
一般数值的用法: | |
numbers.reduce((acc, item)=>acc+item, init_val) reducer函数(acc, item)=>acc+item返回的值类型也是数字型的 | |
一般函数的用法: | |
funcs.reduce((a, b)=>(...args)=>a(b(...args)) reducer函数(a, b)=>(...args)=>a(b(...args)返回的值类型也是函数类型的 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment