Calling underscore as a function will return a wrapped object. Calling chain() on the object allows you to chain subsequent functions.
Created
January 30, 2012 05:49
-
-
Save minikomi/1702793 to your computer and use it in GitHub Desktop.
Chaining using underscore
This file contains hidden or 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
_({first: 1, second: 2, text: 'string here' }) // put object to wrapper | |
.chain() // chaining enabled | |
.compact() // now work with: [1,2, 'string here'] | |
.size() // now: 3 | |
.value() // return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment