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

Wrong type check with undefined. #3

Closed
malash opened this issue May 29, 2018 · 2 comments
Closed

Wrong type check with undefined. #3

malash opened this issue May 29, 2018 · 2 comments

Comments

@malash
Copy link
Member

malash commented May 29, 2018

In this line of code the typeof result could never return undefined so the condition will always be false.

      if (typeof result === undefined) {
        return result;
      }

The correct way to check if a value is undefined could be like typeof result === 'undefined' or result === 'undefined'.

BTW, A strict ESLint check is requested for an open source JavaScript project. The Airbnb one is a good choice.

@ihtml5
Copy link
Member

ihtml5 commented May 30, 2018

Thank you for your suggestion. This is indeed a bug. I will fix it later. After being free, I will perfect eslint detection and unit testing

@ihtml5
Copy link
Member

ihtml5 commented May 30, 2018

It has been fixed. This uses result === void 0 because undefined itself may be modified。

@ihtml5 ihtml5 closed this as completed May 30, 2018
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