Created
March 25, 2018 23:44
-
-
Save FabioAntunes/3a5fe9da7bc7492f85fc961751ebc6bd to your computer and use it in GitHub Desktop.
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
let addOne | |
function add(x, y) { return x + y } | |
addOne = add.bind(null, 1) | |
addOne = x => add(1, x) | |
// new syntax | |
addOne = add(1, ?) | |
// all of the previous examples are equivalent | |
addOne(4) //=> 5 | |
function concat(x, y, z) { return x + y + z } | |
const pad = concat('****', ?, '****') | |
pad('sup') //=> '****sup****' | |
const f = (x, ...y) => [x, ...y] | |
const g = f(?, 1, ...) | |
g(2, 3, 4); //=> [2, 1, 3, 4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment