Boolean valueOf() Method - Javascript Boolean

Javascript examples for Boolean:valueOf

Description

The valueOf() method returns the primitive value of a boolean.

Parameters

None

Return Value:

A Boolean, either "true" or "false"

The following code shows how to return the primitive value of a Boolean object:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//from ww  w . j  a  v a  2s .  co m
    var bool = false;
    var x = bool.valueOf();
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials