Thursday, July 20, 2023

JavaScript Boolean Object

JavaScript Boolean Object

o  It Convert Non-Boolean value to Boolean value.True or False.

o  If I give string or any without quote output will be false

o  If I give string or any with quote output will be True

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

 

    <h2 style="background-color: rgb(9, 238, 9);color:rgb(255, 0, 0);font-weight: bolder;font-family: Georgia, 'Times New Roman', Times, serif;">Boolean Object</h2>

    <h5 style="color: rgb(231, 15, 166);">Output</h5>

    <script type="text/javascript" src="basic.js"></script>

</head>

<body>

   

</body>

</html>

 

 

var b="<br>";

var myBoolean=new Boolean();

document.write(myBoolean);

document.write(b);

var myBoolean=new Boolean(0);

document.write(myBoolean);

document.write(b);

var myBoolean=new Boolean(null);

document.write(myBoolean);

document.write(b);

var myBoolean=new Boolean("");

document.write(myBoolean);

document.write(b);

var myBoolean=new Boolean(false);

document.write(myBoolean);

document.write(b);

var myBoolean=new Boolean(NaN);

document.write(myBoolean);

document.write(b);

var myBoolean=new Boolean(true);

document.write(myBoolean);

document.write(b);

var myBoolean=new Boolean("true");

document.write(myBoolean);

document.write(b);

var myBoolean=new Boolean("false");

document.write(myBoolean);

document.write(b);

var myBoolean=new Boolean("rose");

document.write(myBoolean);

document.write(b);

Output



0 comments:

Post a Comment