Reference Blog: http://blog.csdn.net/zhu7478848/article/details/53388582In Internet Explorer, a Nan error occurs after the JavaScript string is converted to date, but there is no problem with other browsers.Therefore, the format of the string is transformed.var date = new Date ("2016-10-11") under IE date is Nan, while
date to the () object format. For some reason, don't ask me why, the above two browsers are not supported by the date format "YYYY-MM-DD" and therefore fail. I haven't managed to compile a definitive list of supported date formats, but I can tell you that the following format is absolutely supported for all browsers and suggests sticking to one of these to avoid errors:
var d = New Date (2011, 01, 07); //yyyy, MM-1, DD
var d = New Date (2011, 01, 07, 11, 05, 00); //yyyy, MM-1, DD, hh, MM
Strictly judge NaN in JavaScript, while javascript judges nan
I also encountered this question on FreeCodeCamp:
Delete all values in the array.
In JavaScript, the false values include false, null, 0, "", undefined, and NaN.
Fo
In JavaScript, why does ["1", "2", "3"]. map (parseInt) return [1, 2, 3] instead of [1, NaN, NaN]?,. Mapparseint
If the js selection box cannot be selected, I will submit it to jQ. TAT
I hope many people can communicate with each other;
I saw a more detailed explanation on the http://blog.csdn.net/justjavac/article/details/19473199#t0,
But the specific mech
Nan is a value type, and it is also a number. It means not a number, and this all knows what it means. The value is special, especially if Nan is a digit and is a number that is not equal to any number.
Three NaN valuesis a special value that represents the non-number (not a numbers)Type conversion fails to return Nane.g. to convert a word blue to a numeric valu
1.NaNIn JavaScript, Nan represents "not a number". This value is returned primarily when parsing a string error:
Copy Code code as follows:
> Number ("xyz")
Nannan
The name is "not a number", but it can also be said not to a number:
Copy Code code as follows:
> Nan!==
1. NaN
In JavaScript, NaN indicates "not a number". This value is returned when an error occurs in parsing the string:Copy codeThe Code is as follows:> Number ("xyz ")NaNNaN
The name is "not a number", but it can be said that it is not a number:Copy codeThe Code is as follows:> NaN
I believe many beginner JavaScript will have this idea: why JavaScript is null and undefined, relative to C, C + +, Java, they are all just null, why JavaScript is differentOne, historical reasons The web search learned that,when JavaScript was born in 1995, initially, like Java, only null was set as the value represen
a negative number overflows, JavaScript returns a special value "negative zero ". This value (negative zero) is almost the same as normal zero. Javascript programmers seldom use negative zero.
Division by zero does not return an error in javascript: it simply returns infinity or negative infinity (-infinity ). However
= undefined;Null,undefinedfunction Btnclick () {if (tmp = = undefined) {alert ("TMP is undefined!"); }}Analysis: If you use tmp==undefined, the value of TMP will be determined to be true regardless of whether it is null or undefined.2.2. Determine if NULLthe right approach :var tmp = NULL; Null,nan,undefinedfunction Btnclick () {if (!tmp typeof (TMP)! = "undefined" !isnan (tmp)) {ALert ("TMP is null!"); }}Orvar tmp = NULL; Null,
This article mainly introduces how to use the NaN value in JavaScript, which is the basic knowledge in JS learning, A friend may refer to the literal constant NaN without quotation marks as a special value, indicating that it is not a non-number. Since NaN is always a case of unequal comparison, taking any number, incl
This article mainly introduces how to use the NaN value in JavaScript, which is the basic knowledge in JS learning, A friend may refer to the literal constant NaN without quotation marks as a special value, indicating that it is not a non-number. Since NaN is always a case of unequal comparison, taking any number, incl
)); //Show ' object ' 3: alert (typeof(")"); //Display ' string ' 4: alert (typeof(0)); //Show ' number ' 5: alert (typeof(false)); //Show ' Boolean ' 6: 7: var a7 = NaN; 8: var a8 = undefined; 9: : alert (typeof//display "number" One : alert (typeof A8); Show "Undefined"The above indicates that Nan is a special number, and null and undefined are not equal.The function parameter is not and is empty judgment
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 n
caused a change in objcopy. In addition to the above 5 types, there is also a "function"type. [JavaScript] View plaincopyUndefined andNULL, the difference between NaN is described above, it is easy to distinguish undefined from the other two. Undefined determines the type of the variable, while the other two judgments are the value of the variable. Undefined can be used to indicate the following conditions
The following is transferred from: http://blog.csdn.net/hongweigg/article/details/380900931. Question: In JavaScript, typeof (undefined) = = undefined established?Answer: Not true, the global function typeof () returns a value type of string type , six possible values: "Number", "string", "Boolean", "Object", "function", and "undefined".Only typeof (undefined) = = "undefined";is set up.2, typeof (null) = = ' undefined ' established?Answer: Not valid,
"NaN action is used to indicate that a value is not a number"Nan behaves strangely in JavaScript because that Nan and any value are not equal (including itself).Nan = = = Nan; FalseBecause the following code can cause some people
two determine the value of the variable. Undefined can be used to indicate the following conditions 1. represents an undeclared variable, 2. variables declared but not assigned values, 3. null is a special object that indicates no value; NaN is a special number that indicates no value; comparison operator (==or ==) use =. If the types on both sides are different, the js engine first converts them to the same type for comparison of values; Use =, then
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.