How Slow Is JavaScript Really? JavaScript vs. C++ (Data Struct. & Optimization) (youtube.com) 3 points by scanny 5y ago ↗ HN
[–] dheera 5y ago ↗ I felt really stupid when I wrote this yesterday, which you would NEVER do in C++: Promise.allSettled(promises, (results) => { for(i in results) { if(results[i].status === "fulfilled") { .... } } } Like really? We want the processor to test for equality 9 times for "f", "u", "l", "f", "i", "l", "l", "e", "d"? Or is there some built-in optimization for this?Or should I do this, which feels hacky, but reduces it to 1 equality test? const FULFILLED === "f"; Promise.allSettled(promises, (results) => { for(i in results) { if(results[i].status[0] === FULFILLED) { .... } } }
1 comment
[ 5.0 ms ] story [ 16.0 ms ] threadOr should I do this, which feels hacky, but reduces it to 1 equality test?