Following
values are considered as false.
a.
undefined
b.
Null
c.
+0,
−0, or NaN
d.
Empty
string
All other values,
which are not mentioned above, are considered as true.
<!DOCTYPE html> <html> <head> <title>true and false</title> </head> <body> <script type="text/javascript"> var x = ""; var y = "h"; var z = 0; if (x) { document.write("x is true" + "<br />"); } else { document.write("x is false" + "<br />"); } if (y) { document.write("y is true" + "<br />"); } else { document.write("y is false" + "<br />"); } if (z) { document.write("z is true" + "<br />"); } else { document.write("z is false" + "<br />"); } </script> </body> </html>
No comments:
Post a Comment