Example 1 — Official getAges
Build a reusable getter, then pull every age out of a list of people.
const getAges = R.pluck('age');
const people = [
{ name: 'fred', age: 29 },
{ name: 'wilma', age: 27 }
];
console.log(getAges(people)); // [29, 27] How It Works
- Curried.
R.pluck('age')has the key but no list yet, so it returns a function. - Read.
getAges(people)readsagefrom each object:29, then27. - Collect. The values go into a new array in the same order →
[29, 27].
