Javascript booleans reference

Javascript build-in Boolean object reference.

Create booleans:

To create an object: new Boolean(value)
You uses the new keyword to create an object that contains a primitive boolean.
To use as a function: Boolean(value])
When the Boolean object is used as a function the return will be a primitive boolean.
value: An absent value argument results in boolean false.
An example of using the new Number(string):
<script type="text/javascript">
// without any argument
var bool1= new Boolean();
document.write( bool1+"<br>");
// create an Object
var bool2= new Boolean(true);
document.write( bool2+"<br>");
// used as function
var bool3= Boolean(true);
document.write( bool3+"<br>");
</script>

General information about the object member types:

  1. Prototype created methods, properties or constants can only be used on instances of an object or on a primitive datatype.
  2. Constructor created methods, properties or constants can NOT be used on instances of an object or on a primitive datatype.

Prototype Methods:

Syntax: toString()
Returns the string representation of the object which is a primitive string of either 'true' or 'false'.
Return value: The primitive string of the boolean value ('true' or 'false').

Prototype Properties:

Syntax: Boolean.prototype.constructor
This property of the Bollean.prototype holds the reference back to the Boolean object.
Important note: This is the same as the constructor property of an instantiated object

Constructor (Boolean) Properties:

Syntax: Boolean.constructor
The constructor property is a reference to the function that will be invoked to create a Boolean object.

© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.