A summary of JavaScript learning every day (Boolean object) _javascript tips

Source: Internet
Author: User

to create the syntax for a Boolean object:
    New Boolean (value);   //constructor
 & nbsp;  Boolean (value);       //conversion function
    parameter value The value held by a Boolean object or the value to convert to a Boolean value.
return value
    when invoked as a constructor (with operator new), Boolean () converts its arguments to a Boolean value. and returns a Boolean object that contains the value.
    if invoked as a function (without operator new), Boolean () converts its arguments to an original Boolean value and returns the value.
    Note: If the value argument is omitted, or set to 0,-0, NULL, "", false, undefined, or NaN, the object is set to False. Otherwise set to true (even if the value parameter is the string "false").

  var falseobject = new Boolean (false);
  var result = Falseobject && true;
  alert (result); True

  var falsevalue = false;
  result = Falsevalue && true;
  alert (result); False
  
  alert (typeof falseobject);//object
  alert (typeof falsevalue);//boolean
  alert (falseobject Instanceof Boolean); True
  alert (falsevalue instanceof Boolean);//false

Boolean Object Description
In JavaScript, a Boolean value is a basic type of data. A Boolean object is a Boolean object that packs a Boolean value. A Boolean object is primarily used to provide a toString () method that converts a Boolean value to a string.
When the ToString () method is invoked to convert a Boolean value to a string (usually by JavaScript implicitly), JavaScript converts the Boolean value internally to a temporary Boolean object, and then invokes the object's ToString () method.

The above is today's JavaScript learning Summary, and will continue to update every day, I hope you continue to pay attention.

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.