[英]Ramda.js how to pluck with digging object
I want to make an array which have items of id.我想创建一个包含 id 项的数组。
Here is my code.这是我的代码。
const list = [ { meta: { id: 0 } }, { meta: { id: 1 } } ] const result = R.pluck('id')(R.pluck('meta')(list)) // → [0, 1] console.log(result);
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.26.1/ramda.min.js"></script>
I am doing pluck twice and I think this is not cool.我做了两次 pluck,我认为这不酷。
Any coolest way to do this?任何最酷的方法来做到这一点?
I want to use Ramda.js.我想使用 Ramda.js。
Word around town is that this is pretty cool:镇上的一句话是,这很酷:
const list = [ { meta: { id: 0 } }, { meta: { id: 1 } } ] const result = R.map(R.path(['meta', 'id']))(list); console.log(result);
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.26.1/ramda.min.js"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.