let compose = (f, g) => a => f(g(a)) let toUpperCase = x => x.toUpperCase() let exclaim = x => x + '!' let shout = compose(exclaim, toUpperCase); shout("hello world") // HELLO WORLD! |
let sum3 = (a, b, c) => a + b + c let partial = sum3.bind(null, 10, 20) partial(30) // 60 |
let curryingSum3 = (a) => (b) => (c) => a + b + c let curriedSum3 = curryingSum3(30)(20) // [Function] curriedSum3(10) // 60 |
let id = x => x id(id(id(10))) === id(10) // true Math.abs(Math.abs(-1)) === Math.abs(-1) // true |
let greeting = () => 'hello, ' greeting() + 'buddy' |