Last active
February 6, 2020 23:17
-
-
Save chrislaughlin/90ac6fed9d3027f7d382ce6922ebfbc2 to your computer and use it in GitHub Desktop.
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
let testArray = Array(1000000).fill().map((_, i) => i * i); | |
let testMap = new Map(); | |
testArray.forEach(item => testMap.set(item, item)); | |
const find = () => { | |
console.time('Array find'); | |
testArray.find(val => val == 9604) | |
console.timeEnd('Array find'); | |
}; | |
const getFromMap = () => { | |
console.time('Map get'); | |
testMap.get(9604); | |
console.timeEnd('Map get'); | |
} | |
find(); | |
find(); | |
find(); | |
console.log('-------------') | |
getFromMap(); | |
getFromMap(); | |
getFromMap(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment