Discover how to solve nan error in javascript, include the articles, news, trends, analysis and practical advice about how to solve nan error in javascript on alibabacloud.com
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
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
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
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
Null means no value, and undefined represents an undeclared variable, or a variable that has been declared but not assigned a value, or an object property that does not exist.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. You can set the number object to this value to indicate that it is not a numeric value.Null:Indicates that there is no value, but that null its
1 //to replace the original tofixed to solve the accuracy error problem2Number.prototype.mytofixed=function(s) {3 if(s = =NULL) {s = 0;}4 varValue = Math.pow (10,s);//Math.pow (x, y) returns the value of the Y-power of X, which is the value of the 10 len-squared5 //JavaScript's subtraction result will be error, using a custom method6 v
Learn how to use javascript to solve asynchronous programming exceptions. If you are interested, refer
I. Two core difficulties in JavaScript asynchronous programming
Asynchronous I/O and event-driven allow single-threaded JavaScript to execute the network and file access functions without blocking the UI, and enable
.
For example, you cannot write comments, write articles, write comments, and post comments. ("webpage error" or "javascript" is displayed in the lower left corner.) The Password Logon Name is correct but cannot be logged in. The uploaded Avatar and photo cannot be saved.
For example, you cannot write comments, write articles, write comments, and post comments. ("webpage
Javascript: Javascript cross-origin access solution under Controllable conditions on the server side, Javascript tutorial
In a recent web project, I encountered a javascript cross-origin access problem to implement the bookmark function. At first, many solutions searched on Google were not suitable for me. I only saw t
This article mainly introduces how to solve the problem of multiple decimal places in the product operation of Javascript floating point numbers. If you need it, you can refer to the product operation of floating point numbers in Javascript. Multiple decimal places may occur.
This is because the floating point number is converted into a binary number before th
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.