Hacker News new | ask | show | jobs
by IshKebab 668 days ago
Doesn't that exclude NaN (which you probably want despite the name)? I think this really highlights that you probably do want to think about those edge cases...

In any case this is a bad example because Typescript exists.

1 comments

Accepting NaN as a number can potentially crash your app, that's why I reject it in isNumber.

I only tried to highlight some edge cases that I personally don't like to spend energy on, trying to get it right, when writing code. Btw, isNumber is a dynamic call in the example and unrelated to TypeScript. TypeScript doesn't exist at runtime.