Boolean Boolean values in JavaScript use learning and related techniques to explain _javascript skills

Source: Internet
Author: User

The values of two underlying Boolean types in javascript:
1.true
2.false
The Boolean value true represents True and false for false. The generic relational operator returns the result of a Boolean value. In addition, values of 0,-0, NULL, NaN, undefined, and null characters ("") of special values are interpreted as false, and other values are interpreted as true.

function Ismonth (Mon) {
  if (Mon >= 1) && (Mon <=)) {return
    true;
  } else {return
    false;
  }
}
if (Ismonth (Mon)) {
  alert ("OK");
} else {
  alert ("Please enter the correct month.") ");
}

Boolean = new Boolean (value)
generates a Boolean object. Set value to the initial value true or FALSE. In order to conform to the idea that "data types can generate objects" in object-oriented form, JavaScript prepares this class, but it is basically useless.
xx = new Boolean (true);
All types in ECMAScript have values that are equivalent to TRUE or false, and to convert a value to its corresponding Boolean
Value, you can call the Transformation function Boolean ();

Boolean (NaN);//false
boolean (0);//false
Boolean (");//false
Boolean (null);//false
Boolean ( Undefined)//false
PS: You can use!! Operator converts a truthy or Falsy value to a Boolean value.
!! ""//False
!! 0//False
!! Null//False
!! Undefined//False
!! NaN//False
!! " Hello "//True
!! 1//True
!! {}//True
!! []//True

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.