Hacker News new | ask | show | jobs
by masklinn 3994 days ago
`typeof` is useful when the binding may or may not exist at all, this is almost exclusively an issue with global variables which may not be there (toplevel APIs or libraries missing).

If the binding exists at all, you can just check for its value. And parameters always create a binding pretty much by definition.

So no, there is no reason to use `typeof` to check whether a parameter is `undefined`.

If you fear that somebody rebound the global `undefined` for some insane reason, you can use `void 0` instead.