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

  • SEARCH
  • Home
  • 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 7946639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:12:46+00:00 2026-06-04T01:12:46+00:00

We know that by default, the ‘obj’ below is string. Without using ‘parseInt’, how

  • 0

We know that by default, the ‘obj’ below is string. Without using ‘parseInt’, how does JavaScript compare it with a number?

obj = document.frm.weight.value;
if( obj < 0 || obj > 5 ){
    alert("Enter valid range!");
    return false;
}
  • 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-06-04T01:12:47+00:00Added an answer on June 4, 2026 at 1:12 am

    If one of the operands of < or > is number, the other one will be casted to a number.

    alert("3" > 3);   // false
    alert("3.5" > 3); // true
    

    EDIT and further explanation:

    If it is not possible to cast the other parameter into a number, it is casted into the special value called NaN – the abbreviation stands for “Not a Number”. The NaN value has a special property that it is absolutely incomparable – all relation operators like <, > and = will return false if one of the arguments is NaN.

    alert("" > 3);      // false
    alert("3.5?" > 3);  // false
    alert({} > 3);      // false
    

    Also, note that in the second line, if we used

    alert(parseInt("3.5?") > 3);
    

    it would alert true, because parseInt reads "3.5" from the string "3.5?", then stops reading at "?" and thus evaluates to 3.5. However,

    alert("3.5?" > 3);
    

    returns false because the cast from string to number is not as benevolent as parseInt. As "3.5" indeed isn’t a number, it is casted to NaN.

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

Sidebar

Related Questions

Does anybody know how to disable the default CKEditor behavior that changes the RichCombo
I know that component-model indicates whether a property has a default value or not,
I know that user accounts in Windows 7 are limited by default, so a
I know mongrel is the default server for script/server but when I do that
I know that log4j by default outputs to stderror. I have been capturing the
Simple question. I know that in the default MVC application in Visual Studio, you
I know that default cron's behavior is to send normal and error output to
I know that default WPF behavior is to render WPF controls and then on
I have been reading around and know that by default jQuery within a the
i've been searching and i know that float:left or float whatever does that, but

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.