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 array = [{id:1}, {id:2}, {id:3}, {id:4}, {id:5}, {id:2}, {id:6}, {id:4}, {id:7}]; | |
function unique(array, propertyName) { | |
return array.filter((e, i) => array.findIndex(a => a[propertyName] === e[propertyName]) === i); | |
} | |
console.log(unique(array, 'id')) | |
/* | |
output: | |
[{"id":1},{"id":2},{"id":3},{"id":4},{"id":5},{"id":6},{"id":7}] |
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 array = [1, 2, 3, 1, 3, 4, 5, 2]; | |
const uniqueArray = [...new Set(array)]; | |
console.log(uniqueArray) | |
// output: [1, 2, 3, 4, 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 deep2array = [ | |
['abc1', 'bcd1', 'def1'], | |
['abc2', 'bcd2', 'def2'], | |
['abc3', 'bcd3', 'def3'] | |
]; | |
const shallowFlatten = (p, c) => [...p, ...c]; | |
console.log(deep2array.reduce(shallowFlatten, [])) | |
/* output: | |
["abc1", "bcd1", "def1", "abc2", "bcd2", "def2", "abc3", "bcd3", "def3"] |
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
# <IMAGE_NAME> - target image name in docker | |
# docker logs -f $(docker ps -q --filter="ancestor=<IMAGE_NAME>") | |
docker logs -f $(docker ps -q --filter="ancestor=mongo:3.3") |
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 arr = [1,2,3] | |
const min = Math.min(...arr); | |
const max = Math.max(...arr); | |
console.log('min:', min, 'max:', max); // output => min: 1 max: 3 |
NewerOlder