Skip to content

Instantly share code, notes, and snippets.

@silppuri
Last active December 31, 2015 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silppuri/8013616 to your computer and use it in GitHub Desktop.
Save silppuri/8013616 to your computer and use it in GitHub Desktop.
Late night playtime with es6 arrow functions
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