long hand: 0.12499996228143573
short hand 1: 0.7600000244565308
short hand 2: 0.1700000138953328
Long hand is faster because you don't need to waste time and memory space building an array. Premature optimization is the root of all evil. Just keep things simple.
just make a dictionary and get your value. what's the point? well in this situation nothing besides being faster. in a particular situation? avoiding checking every single condition if you already know what you are checking for. Every book should get rid of switch condition, and you should avoid that much if statements in your methods. imho
56
u/dethstrobe May 06 '21
A quick performance check. https://codesandbox.io/s/awesome-jones-2fpy1?file=/src/index.js
Long hand is faster because you don't need to waste time and memory space building an array. Premature optimization is the root of all evil. Just keep things simple.