JavaScriptUndefined, difference between the Null type and the NaN value _ basic knowledge
Source: Internet
Author: User
Differences between null values and undefined values in Javascript
Undefined type Only one undefined Value
The following three types of typeof return types are undefined:
1. When the variable is not initialized
2. When the variable is undefined
3. When the function does not return a specific value (undefined is returned when the function does not return a value)
Undefined is not equivalent to an undefined value.
Typeof does not really distinguish whether it is undefined
See the following sample code:
Var oTemp;
Alert (typeof oTemp); // outputs "undefined"
Alert (typeof oTemp2); // outputs "undefined"
Alert (oTemp2 = undefined); // error oTemp2 undefined cannot use operations other than typeof but not oTemp2
When the variable
Binary Null type There is only one null. undefined is derived from null, so undefined = null
Undefined is a variable declared but not initialized,
Null indicates that no existing object exists.
Three NaN values Is a special value, indicating a non-Number (Not a Number)
If the type conversion fails, NaN is returned.
E.g. to convert a word blue to a value, it will fail because there is no equivalent value.
NaN is not equal to yourself
That is, NaN = NaN is false.
Determine whether NaN uses isNaN ();
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