Skip to content

Instantly share code, notes, and snippets.

@ischenkodv
Last active December 14, 2015 22:19
Show Gist options
  • Save ischenkodv/5157752 to your computer and use it in GitHub Desktop.
Save ischenkodv/5157752 to your computer and use it in GitHub Desktop.
Underscore.js chaining
// Compose function
var cleanArray = _.compose(_.compact, _.uniq, _.flatten);
result = cleanArray(lottery);
// Chainable way
result = _.chain(lottery)
.flatten()
.uniq()
.compact()
.value()
// source: http://www.miniarray.com/blog/chaining-in-underscore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment