Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7071979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:45:10+00:00 2026-05-28T05:45:10+00:00

I am using isNan functionto check if entered value is a number: if(isNaN(num)) {

  • 0

I am using isNan functionto check if entered value is a number:

if(isNaN(num)) {
    alert('I am not a number');
}
else {
//
     }

However, if entered value is, for example, “5748hh” it is understandable like a number and return false. What is wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:45:10+00:00Added an answer on May 28, 2026 at 5:45 am

    from Mozilla MDN

    When the argument to the isNaN function is not a number, the value is first coerced to a number. The resulting value is then tested to determine whether it is NaN. Thus for non-numbers that when coerced to numeric type result in a valid non-NaN numeric value (notably the empty string and boolean primitives, which when coerced give numeric values zero or one), the “false” returned value may be unexpected; the empty string, for example, is surely “not a number.” The confusion stems from the fact that the term, “not a number”, has a specific meaning for numbers represented as IEEE-794 floating-point values. The function should be interpreted as answering the question, “is this value, when coerced to a numeric value, an IEEE-794 ‘Not A Number’ value?”

    so alert(isNaN('45345ll')) returns true because its value coercion is different than a parseInt/parseFloat conversion.

    e.g.

    var num = false;
    console.log(isNaN(num));        /* return false because the coerced value is 0 but */
    console.log(parseInt(num, 10)); /* return isNaN */
    

    Maybe you get an unexpected value due to a missing paren in your if statement

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been using the is_nan() function (i.e. is-not-a-number) to check whether a variable taken
I was using isNaN function in a Facebook application, but it was not working.
When using a returned value to determine the number of an element in an
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Is it a good idea to use IEEE754 floating point NaN (not-a-number) for values
I am using isNaN to evaluate input in text box my function is like
I need using javascript to check if the current user is fan of my
I was using sum(is.na(my.df)) to check whether my data frame contained any NAs, which
I need to work on a project using open source software, mahout. An example
Using online interfaces to a version control system is a nice way to have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.