- // Use in place of `[]`.
- const list1 = Immutable.List(['A', 'B', 'C']);
- const list2 = list1.push('D', 'E');
- console.log([...list1]); // ['A', 'B', 'C']
- console.log([...list2]); // ['A', 'B', 'C', 'D', 'E']
- // Use in place of
推荐阅读
沙龙晃荡 | 去哪儿、陌陌、ThoughtWorks在主动化运维中的实践!10.28不见不散! 几周前,我们开端写一个系列,>>>详细阅读
地址:http://www.17bianji.com/lsqh/38230.html
1/2 1
JavaScript的函数式编程,你了解吗?
作者: 来源: 2017-10-26 09:46:30 阅读次 我要评论
'sedan', price: 24195 }, { make: 'Mazda', model: 'CX-9', type: 'suv', price: 31520 }, { make: 'Toyota', model: '4Runner', type: 'suv', price: 34210 }, { make: 'Toyota', model: 'Sequoia', type: 'suv', price: 45560 }, { make: 'Toyota', model: 'Tacoma', type: 'truck', price: 24320 }, { make: 'Ford', model: 'F-150', type: 'truck', price: 27110 }, { make: 'Ford', model: 'Fusion', type: 'sedan', price: 22120 }, { make: 'Ford', model: 'Explorer', type: 'suv', price: 31660 } ]; // Using `pipe` executes the functions from top-to-bottom. const averageSUVPrice1 = R.pipe( R.filter(v => v.type === 'suv'), R.map(v => v.price), R.mean )(vehicles); console.log(averageSUVPrice1); // 33399 // Using `compose` executes the functions from bottom-to-top. const averageSUVPrice2 = R.compose( R.mean, R.map(v => v.price), R.filter(v => v.type === 'suv') )(vehicles); console.log(averageSUVPrice2); // 33399
关键词: 探索发现
乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。
网友点评
精彩导读
品牌展示

科技快报