Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

es6 map(). reduce()连用,求教执行顺序

比如一个数组a
a. map(item=>...). ruduce()
是执行完map 里面然后返回值再执行reduce,还是依次map再reduce?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

为什么map支持链式调用?因为这个函数的返回值也是一个数组。
所以是对这个函数返回值进行reduce操作。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...