码迷,mamicode.com
首页 > 其他好文 > 详细

[Ramda] Pluck & Props: Get the prop(s) from object array

时间:2016-10-10 01:38:34      阅读:85      评论:0      收藏:0      [点我收藏+]

标签:

Pluck:

Get one prop from the object array:

R.pluck(a)([{a: 1}, {a: 2}]); //=> [1, 2]
R.pluck(0)([[1, 2], [3, 4]]);   //=> [1, 3]

 

Props:

R.props([x, y], {x: 1, y: 2}); //=> [1, 2]
R.props([c, a, b], {b: 2, a: 1}); //=> [undefined, 1, 2]

var fullName = R.compose(R.join( ), R.props([first, last]));
fullName({last: Bullet-Tooth, age: 33, first: Tony}); //=> ‘Tony Bullet-Tooth‘

 

[Ramda] Pluck & Props: Get the prop(s) from object array

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/5944394.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!