This file contains hidden or 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 xs = { | |
| template: [ | |
| {template: 'one', dest: 'two'}, | |
| {template: 'one', dest: 'two'} | |
| ], | |
| copy: [ | |
| {template: 'one', dest: 'two'}, | |
| {template: 'one', dest: 'two'} | |
| ] | |
| }; |
This file contains hidden or 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
| const generator = (x, y = x) => { | |
| return {x: `_${x}`, y}; | |
| }; |
This file contains hidden or 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
| const xs = [1, 2, 3, 4, 5]; | |
| const [ x ] = xs.slice(-1); //=> 5 |
This file contains hidden or 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
| const xs = [1, 2, 3, 4, 5]; | |
| const x = xs[xs.length - 1]; //=> 5 |
This file contains hidden or 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
| const xs = [1, 2, 3, 4, 5]; | |
| const x = xs.pop(); //=> 5 |
This file contains hidden or 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
| const xs = [1, 2, 3, 4, 5]; | |
| const [ x ] = xs.reverse() //=> 5 |
This file contains hidden or 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
| const xs = [1, 2, 3, 4, 5]; | |
| const x = xs.reverse().shift() //=> 5 |
This file contains hidden or 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
| const xs = [1, 2, 3, 4, 5]; | |
| const [ x ] = xs.filter((x, index, array) => { | |
| return index === array.length); | |
| }); // => 5 |
This file contains hidden or 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
| const compose = (...rest) => ( | |
| (z) => rest.reverse().reduce((x, y) => y(x), z) | |
| ); | |
| const compose2 = (fn, ...rest) => ( | |
| (rest.length === 0) ? fn :(z) => compose2(...rest)(fn(z)) | |
| ); |
This file contains hidden or 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
| const length = ([head, ...tail]) => ( | |
| (head === void 0) ? 0 : 1 + length(tail) | |
| ); |