@mathias
I have a very serious question :) Is it better in case of performance in V8 to cast function to boolean explicitly? like `if (foo) {}` vs `if (!!foo) {}`?
`if (foo)` triggers a ToBoolean conversion behind the scenes. In the case of `if (!!foo)` you’re just moving that ToBoolean conversion to *your* code.
-
-
In general, don’t worry about micro-optimizations like these. They’re not going to make a difference in terms of real-world app performance.
-
But what if it's a library which aim is performance? Will it be a micro-optimization if I invoke toBoolean in my code instead of V8?
- 2 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.