Skip to content

Instantly share code, notes, and snippets.

@khoand0000
Last active December 30, 2015 12:46
Show Gist options
  • Save khoand0000/14436c9662769df8c38e to your computer and use it in GitHub Desktop.
Save khoand0000/14436c9662769df8c38e to your computer and use it in GitHub Desktop.
_.invoke() vs. _.each() vs. _.map()

_.invoke() vs. _.each() vs. _.map(): read http://stackoverflow.com/questions/13193959/difference-between-underscore-js-each-method-and-invoke-method

  • _.invoke(list, methodName, *arguments) methodName is string, is function belongs to object object.methodName(...). return result as _.map()
  • _.each(list, iteratee, [context]) iteratee is not string (a function name). iteratee is called for each object/item as its parameter iteratee(object). return no result
  • _.map(list, iteratee, [context]) like _.each(), apply iteratee for each item iteratee(object), but difference is that return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment