Export (0) Print
Expand All

prototype Property (Boolean)

Returns a reference to the prototype for a Boolean.

boolean.prototype

The boolean argument is the name of an object.

The prototype property provides a base set of functionality to a class of objects. New instances of an object "inherit" the behavior of the prototype assigned to that object. Properties and methods may be added to the prototype, but builtin objects may not be assigned a different prototype.

For example, to add a method to the Boolean object that returns the value of the largest element of the array, declare the function, add it to Boolean.prototype, and then use it.

function isFalse( ){
    if (this.toString() == "false")
         return true;
    else
        return false;
}
Boolean.prototype.isFalse = isFalse;
var bool = new Boolean(1);
document.write(bool.isFalse());

// Output:
// false

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

Show:
© 2014 Microsoft