Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: Why use typeof #78

Open
peterorosz opened this issue Oct 28, 2016 · 1 comment
Open

Q: Why use typeof #78

peterorosz opened this issue Oct 28, 2016 · 1 comment

Comments

@peterorosz
Copy link

Hi, firstly I'd like to thank you for writing a great book. I purchased it yesterday and already found it very helpful.

One question I have concerns the way you validate whether /api/get/{id} returns an actual result from the database:

if (typeof result !== 'undefined') {
    return reply(result);
}

Why not take advantage of the type coercion and simply:

if (result) {
    return reply(result);
}

Does typeof cover some exceptional cases I do not foresee?

Thank you very much!

@Cifer-Y
Copy link

Cifer-Y commented Dec 17, 2016

I also want to know that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants