revision:
toSource() : returns a string containing the source of the Boolean object; you can use this string to create an equivalent object.
Deprecated
toString() : returns a string of either "true" or "false" depending upon the value of the object.
syntax:
let bool = true;
let text = bool.toString();
console.log(text) // true
valueOf() : returns the primitive value of the Boolean object.
syntax:
const x = new Boolean();
console.log(x.valueOf()); // Expected output: false
const y = new Boolean("Mozilla");
console.log(y.valueOf()); // Expected output: true
<div>
<p>boolean.toSource() </p>
<a class="spec" id="boolean1"></a><br>
<p>boolean.toString()</p>
<a class="spec" id="boolean2"></a><br>
<p>boolean.valueOf()</p>
<a class="spec" id="boolean3"></a><br>
</div>
<script>
function book(title, publisher, price) {
this.title = title;
this.publisher = publisher;
this.price = price;
}
var newBook = new book("Perl","Leo Inc",200);
document.getElementById("boolean1").innerHTML = JSON.stringify(newBook);
var flag = new Boolean(false);
document.getElementById("boolean2").innerHTML = "flag.toString is : " + flag.toString();
var flag1 = new Boolean(false);
document.getElementById("boolean3").innerHTML = "flag.valueOf is : " + flag.valueOf();
</script>