Ways to use Nan values in JavaScript

Source: Internet
Author: User
Tags access properties valid

This article mainly introduces the use of Nan value in JavaScript, is the basic knowledge of JS introductory learning, the need for friends can refer to the

literal constant without quotes Nan is a special value that represents not a non-numeric number. Because Nan is always in a relatively unequal situation, in any number, including Nan, it is usually an error condition for a function that indicates that a valid number should be returned.

Note: Use the isNaN () global function to see if the value is a Nan value.

Grammar

You can access properties using the following syntax:

?

1 var val = Number.NaN;

Example:

Here, DayOfMonth assigns Nan, if it is greater than 31, and displays a message indicating the valid range:

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24-25

This will produce the following results:

?

1 Day of Month must is between 1 and 31. Value of Dayofmonth:nan
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.