Created
April 19, 2014 16:36
-
-
Save piecyk/11089712 to your computer and use it in GitHub Desktop.
Exmaple using undersorejs Chaining Methods with Arrow functions |
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
var stooges = [{name: 'curly', age: 25}, {name: 'moe', age: 21}, {name: 'larry', age: 23}]; | |
var youngest = _.chain(stooges) | |
.sortBy(function(stooge){ return stooge.age; }) | |
.map(function(stooge){ return stooge.name + ' is ' + stooge.age; }) | |
.first() | |
.value(); | |
== "moe is 21" | |
== and with Arrow functions | |
var youngest = _.chain(stooges) | |
.sortBy(stooge => stooge.age) | |
.map(stooge => stooge.name + ' is ' + stooge.age) | |
.first() | |
.value(); | |
== "moe is 21" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment