Tutorials » Javascript tutorials »

Boolean Object - An Example

This article explains an example that shows boolean object 's creation

Now let’s try to implement things that we have learned from previous chapter

Save following sample code as bool .html and run in the browser to understand the basic differences for boolean object arguments .



<script type="text/javascript">

document.write("<br/>When double quotes passed ---</br> ")

document.write( b = new Boolean("") + "<br/>")

document.write("<br/>When nothing is passed --- </br>")

document.write(b = new Boolean() + "<br/>")

document.write("<br/>When false is passed --- </br> ")

document.write(b = new Boolean(false) + "<br/>")

document.write("<br/>When NAN is passed ---</br> ")

document.write(b = new Boolean(NaN) + "<br/>")

document.write("<br/>When nulll is passed --- <br/>" )

document.write(b = new Boolean(null) + "<br/>")

document.write("<br/>When undefined is passed ---<br/> ")

document.write(b = new Boolean(undefined) + "<br/>")

document.write("<br/>When 0 is passed --- <br/>")

document.write(b = new Boolean(0) + "<br/>")

document.write("<br/>When true with quotes passed---<br/> ")

document.write(b = new Boolean("true") + "<br/>")

document.write("<br/>When false with quotes passed ---<br/>")

document.write(b = new Boolean("false") + "<br/>")

document.write("<br/>When true passed --- <br/>")

document.write(b = new Boolean(true) + "<br/>")

document.write("<br/>When 1 is passed --- <br/>")

document.write(b = new Boolean(1) + "<br/>")





Next Chapter: Understanding Events
Previous Chapter: The Boolean Object
More Chapters: Javascript Tutorials
More Tutorials: Tutorial Index

Top Contributors
    Last 7 Daysmore...

    Awards & Gifts

    Online Members

    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India