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

'-' or '+' will pass test of isFloat? #751

Closed
robberfree opened this issue Nov 23, 2017 · 1 comment · Fixed by #752
Closed

'-' or '+' will pass test of isFloat? #751

robberfree opened this issue Nov 23, 2017 · 1 comment · Fixed by #752
Labels

Comments

@robberfree
Copy link

robberfree commented Nov 23, 2017

I found

isFloat('-')//true
isFloat('+')//true

but

toFloat('-')//NaN
toFloat('+')//NaN

maybe it's a bug?

@robberfree
Copy link
Author

@linkinmedo thanks a lot.
maybe better to promote this line

if (str === '' || str === '.' || str === '-' || str === '+') {
    return false;
  }

then we can tell user the test result quickly without building a new RegExp.
thanks again.

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

Successfully merging a pull request may close this issue.

2 participants