[Ramda] Pluck & Props: Get the prop(s) from object array
Posted Answer1215
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Ramda] Pluck & Props: Get the prop(s) from object array相关的知识,希望对你有一定的参考价值。
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的主要内容,如果未能解决你的问题,请参考以下文章