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
// fetch api | |
{ | |
posts: [ | |
{ | |
id: 88, | |
content: 'North Korea News', | |
author: { | |
id: 41, | |
name: 'Kim Jong-un', | |
}, |
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
/** all pure func avoid push, pop, shift, unshift, sort, reverse, splice and delete */ | |
/** | |
* @param {[array]} array | ['USD', 'JPY', 'GBP'] | | |
* @param {[number]} index | 0 | | |
* @return {[array]} array | ['JPY', 'GBP'] | delete element of array by index and return new array | |
*/ | |
const deleteByIndex = ( array, index ) => | |
array.slice( 0, index ).concat( array.slice( index + 1 ) ) |
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
Head & Tail | |
Destructuring syntax allows us to get the head and tail of a list without utility functions. | |
_.head([1, 2, 3]); | |
// 1 | |
_.tail([1, 2, 3]); | |
// [2, 3] | |
// becomes |
NewerOlder