Last active
December 31, 2015 16:29
-
-
Save silppuri/8013616 to your computer and use it in GitHub Desktop.
Late night playtime with es6 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 arr = [25,26,29,59,16,1325,3]; | |
var id = (x) => _ => x; | |
var gt = (b) => a => a > b; | |
arr.filter(gt(25)); // [26, 29, 59, 132] | |
var people = [ | |
{name: "John", age: 45}, | |
{name: "Fantomas", age: 34}, | |
{name: "Seppo", age: 59} | |
]; | |
var eq = (fn, target) => _ => fn(_) === target; | |
var key = key => obj => obj[key]; | |
people.filter(eq(key('name'), 'Seppo')); //[{name: "Seppo", age: 59}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment