In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces what is the use of nan in javascript. The article is very detailed and has certain reference value. Interested friends must read it!
javascript nan is a special value representing a non-numeric value. This attribute is used to indicate that a value is not a number. The Number object can be set to this value to indicate that it is not a numeric value. Its syntax is "Number.NaN".
Operating environment: Windows 7 system, javascript version 1.8.5, DELL G3 computer.
What does Javascript Nan mean?
JavaScript NaN Properties
The NaN property is a special value that represents a non-numeric value. This property is used to indicate that a value is not a number. The Number object can be set to this value to indicate that it is not a numeric value.
Tip: Use the isNaN() global function to determine whether a value is a NaN value.
syntax
Number.NaN
description
Number.NaN is a special value indicating that the result of some arithmetic operation (such as finding the square root of a negative number) is not a number. The methods parseInt() and parseFloat() return this value when the specified string cannot be parsed. For some functions that return significant numbers in the normal case, you can also use this method to describe its error case with Number.NaN.
JavaScript outputs Number.NaN as NaN. Note that NaN is always unequal when compared to other values, including itself. Therefore, you cannot compare with Number.NaN to detect whether a value is a number, but you can only call isNaN() to compare.
In ECMAScript v1 and later, you can also replace Number.NaN with the predefined global attribute NaN.
Tips and comments
Tip: Use isNaN() to determine if a value is a number. The reason is that NaN is not equal to all values, including itself.
examples
Use NaN to indicate whether a value is a number:
var Month=30;if (Month
< 1 || Month >12){Month = Number.NaN;}[xss_clean](Month);
Output:
Nan above is "javascript nan has what to use" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.