Skip to content

Instantly share code, notes, and snippets.

@tiggerk
Last active January 6, 2018 05:26
Show Gist options
  • Select an option

  • Save tiggerk/12c0360fe49f6f0330aff7712d1d57c5 to your computer and use it in GitHub Desktop.

Select an option

Save tiggerk/12c0360fe49f6f0330aff7712d1d57c5 to your computer and use it in GitHub Desktop.
Migrating to loadsh from Underscore
  • Underscore _.any is Lodash _.some
  • Underscore _.compose is Lodash _.flowRight
  • Underscore _.contains is Lodash _.includes
  • Underscore _.each doesn’t allow exiting by returning false
  • Underscore _.findWhere is Lodash _.find
  • Underscore _.flatten is deep by default while Lodash is shallow
  • Underscore _.indexBy is Lodash _.keyBy
  • Underscore _.invoke is Lodash _.invokeMap
  • Underscore _.mapObject is Lodash _.mapValues
  • Underscore _.max combines Lodash _.max & _.maxBy
  • Underscore _.min combines Lodash _.min & _.minBy
  • Underscore _.object is Lodash _.zipObject
  • Underscore _.pairs is Lodash _.toPairs
  • Underscore _.pluck is Lodash _.map
  • Underscore _.uniq by an iteratee is Lodash _.uniqBy
  • Underscore _.where is Lodash _.filter
  • Underscore _.isFinite doesn’t align with Number.isFinite (e.g. _.isFinite('1') returns true in Underscore but false in Lodash)
  • Underscore _.matches shorthand doesn’t support deep comparisons (e.g. _.filter(objects, { 'a': { 'b': 'c' } }))
  • Underscore ≥ 1.7 & Lodash _.template syntax is _.template(string, option)(data)
  • Lodash _.memoize caches are Map like objects
  • Lodash supports implicit chaining, lazy chaining, & shortcut fusion
  • Lodash split its overloaded _.head, _.last, _.rest, & _.initial out into _.take, _.takeRight, _.drop, & _.dropRight (i.e. _.head(array, 2) in Underscore is _.take(array, 2) in Lodash)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment