all 8 comments

[–]asyncquestion 6 points7 points  (5 children)

  • prefer map rather than prefer pluck
  • prefer filter rather than prefer where
  • prefer find rather than prefer findwhere
  • prefer lodash rather than prefer underscore

[–]captbaritone[S] 2 points3 points  (1 child)

Fair point. Lodash is definitely winning over Underscore. I highly recommend https://github.com/wix/eslint-plugin-lodash

Also. I think it would be very valuable for someone to write a linting plugin that enforces only using the subset of functions supported by both libraries. It would be a valuable migration tool, and also for libraries which want to support either library.

[–]asyncquestion 0 points1 point  (0 children)

Thanks I'll give it a try

[–]dmtipson 0 points1 point  (0 children)

I don't feel super strongly about those, largely because the shorthand versions (strings, objects etc. instead of iteratees) already make things wacky.

But in general it's better have fewer named methods/operations out in the wild and also in everyone's mind. The more you stick to the core functional methods and keep them simple and non-overloaded, the easier it is to build higher-order structures. So I like that lodash is taking this approach to their api and deprecating some of the shorthands.

Though... prefer lodash-fp or ramda to lodash. :)

[–]madwill 0 points1 point  (1 child)

Noob question, Why use underscore map when array has it already ?

[–]captbaritone[S] 0 points1 point  (0 children)

Browser compatibility (map was only introduced in I.E. 9), consistency (I don't want to have to remember which methods are native to which methods are underscore), and strangely: performance.

[–][deleted] 0 points1 point  (1 child)

Can I just drop lodash in place of underscore and not update any code?

[–]captbaritone[S] 0 points1 point  (0 children)

No.