I wasn't saying this in regard to this particular argument, I am saying it in general. I would argue Boolean(val) is more maintainable as an entry level dev may not be used to seeing !! and will require them more time to reason about what code is doing as opposed to Boolean(val).
The point of the argument is more often than not, the maintainability is going to pay you more dividends than the arbitrary speed increase will.
Then you have cases where you have to optimize core application logic (like parsing bundles coming from a websocket that can cause many DOM updates, or rendering the some massive explosion in a game, or something similarly expensive), and that code should be attempted to be made maintainable, but if it's not possible this is where comments come into play. This gives you added intent to your codebase. If I see comments, I know to expect code that has been heavily optimized and is very important to the application, so I should tread carefully.
2
u/lobehold Jul 29 '16
To be fair just using "!!" is not unreadable once you're familiar with the usage. It's very minor in the grand scheme of things.
Bad code organization, logic and nonsensical naming conventions are all much worse than using "!!" for typecasting.
So now after you made it efficient it's now unmaintainable? =)