Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

If I'm understanding get() correctly here, why not just use:

    var totals = orders.map(get("total"));
Why needlessly use specialized jargon when common terms work just fine?


That's fine, as is _.map(orders, get('total')) or just plain map(orders, get('total')). As I explained in another comment, splat is a combinator, which makes it particularly easy to compose. Compare:

    function pluck (list, propertyName) {
      return _.map(list, get(propertyName));
    };
to:

    var pluck = compose(splat, get);
So yes, for that one line you should use map, but when making things out of the mapping construct, it is sometimes handy to use splat.

Other folks have introduced the idea that splat is really nothing more than flip(curry(map)). There's a good argument for better naming once you realize the underlying symmetry.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: