Last active
December 14, 2015 22:19
-
-
Save ischenkodv/5157752 to your computer and use it in GitHub Desktop.
Underscore.js chaining
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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