4 ms·
And a comment on its own would be enough anyway
by HuangYuSan 3y ago
And a comment on its own would be enough anyway
- earthboundkid 3y agoYeah, ideally you’d have some kind of static typing to restrict the code to only use Number, and then a comment that says what the function does in case of NaN.
- carapace 3y agoYeah! There was a thread the other day about a linter that flagged useless code and all the odd bugs it caught, and I think it would have flagged this snippet, eh? "Interesting bugs caught by no-constant-binary-expression" https://news.ycombinator.com/item?id=38196644 https://news.ycombinator.com/item?id=38196644 https://eslint.org/blog/2022/07/interesting-bugs-caught-by-no-constant-binary-expression/ https://eslint.org/blog/2022/07/interesting-bugs-caught-by-n...