We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
prefer-number-is-integer
Use Number.isInteger. Not really sure if there's any benefit to using it. Maybe it's more performant. Makes the code marginally cleaner.
Number.isInteger
number % 1 === 0;
Number.isInteger(number);
The text was updated successfully, but these errors were encountered:
Makes the code marginally cleaner.
Marginally cleaner is an understatement. number % 1 === 0; is extremely unreadable and also fails if the passed in variable is not a number:
let number = [['1']]; // ... number % 1 === 0; //=> true
Some more cases it could catch: https://stackoverflow.com/a/34848042/64949
And it could also catch _.isInteger.
_.isInteger
Sorry, something went wrong.
This is now accepted.
If anyone wants to work on this, see the initial attempt and feedback in #1509
Successfully merging a pull request may close this issue.
Use
Number.isInteger
.Not really sure if there's any benefit to using it. Maybe it's more performant. Makes the code marginally cleaner.
Fail
Pass
The text was updated successfully, but these errors were encountered: