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 data = { | |
other: 'skip', | |
prefix1: 'take1', | |
prefix2: 'take2', | |
}; | |
const prefixedValues = Object.entries(data) | |
// Get only entries with keys staring with prefix | |
.filter(([key, value]) => key.startsWith('prefix')) | |
// Get only values |
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
function simpleIterator() { | |
const iterator = { | |
next() { | |
return { | |
value: "Hello, I'm an iterator", | |
done: true, | |
}; | |
}, | |
}; |
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 startTimestamp = getMiliseconds(); | |
function getMiliseconds() { | |
return new Date(Date.now()).getMilliseconds(); | |
} | |
function getMillisecondsElapsed() { | |
return getMiliseconds() - startTimestamp; | |
} |