JSFiddle - React, Tailwind, and code Playground

by javascriptenlightenment

HTML

<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
<!-- disregard this pane, html is shown in the "result" pane -->




































































<h4><strong>&larr; Code Example from <a href="http://www.javascriptenlightenment.com/" target="_blank">JavaScript Enlightenment Book</a> by <a href="http://www.codylindley.com" target="_blank">Cody Lindley</a></strong></h4>

<p>JavaScript code is executed on page load. Click the "Run" button in the top bar to re-run the JavaScript code. Output is logged to the <a href="http://getfirebug.com/firebuglite" target="_blank">Firebug Lite</a> console below &darr;.</p>

JavaScript

// create boolean object using the new keyword and the Boolean() constructor
var myBoolean1 = new Boolean(false); // using new keyword
console.log(typeof myBoolean1); // logs 'object'

// create boolean literal/primitive by directly using the number constructor without new
var myBoolean2 = Boolean(0); // without new keyword
console.log(typeof myBoolean2); // logs 'boolean'

// create boolean literal/primitive (constructor leveraged behind the scene)
var myBoolean3 = false;
console.log(typeof myBoolean3); // logs 'boolean'
console.log(myBoolean1, myBoolean2, myBoolean3); // logs false false false