JavaScript True/false

Source: Internet
Author: User

JavaScript evaluates to false values: null, False, 0, undefined, NaN, and "" (empty string). Remember that the value of this Nan class like Infinity (Infinity) is judged to be true and not false. However, NaN is judged false. In addition to these, all other values are judged to be true.

One Undefined type
There is only one value undefined
The following three cases typeof return type is undefined
1. When the variable is not initialized
2. When a variable is not defined
3. When the function has no explicit return value (undefined is returned when the function has no return value)
Undefined is not equivalent to undefined value
typeof does not really differentiate whether it is undefined
Look at the following sample code:
var otemp;
Alert (typeof otemp); Outputs "undefined"
Alert (typeof OTEMP2);//outputs "undefined"
Alert (OTEMP2 = = undefined); Error OTEMP2 undefined cannot use other operations except typeof that cannot be used to OTEMP2 other
When the variable
two Null type
Only one null,undefined is handled by a null derivation, so undefined = = NULL
Undefined is the variable declared but not initialized,
Null indicates an object that does not exist
three NaN value
is a special value that represents a non-number (not a digit)
Type conversion failure will return Nan
e.g. to convert a word blue to a numeric value will fail because there is no equivalent value
NaN does not equal itself
That is, Nan = = Nan is False
Judge Nan using IsNaN ();

JavaScript True/false

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.