Home
<!DOCTYPE html> <html> <body> <h1>Demo: JavaScript Boolean</h1> <p id="p1">Boolean('') returns </p> <p id="p2">Boolean(0) returns </p> <p id="p3">Boolean(null) returns </p> <p id="p4">Boolean(undefined) returns </p> <script> var b1 = Boolean(''); // false var b2 = Boolean(0); // false var b3 = Boolean(null); // false var a; var b4 = Boolean(a); // false document.getElementById("p1").textContent += b1; document.getElementById("p2").textContent += b2; document.getElementById("p3").textContent += b3; document.getElementById("p4").textContent += b4; </script> </body> </html>
Result: