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

// string object treated like an object
var stringObject = new String('foo');
console.log(stringObject.length); // logs 3
console.log(stringObject['length']); // logs 3

// string literal/primitive converted to an object when treated as an object
var stringLiteral = 'foo';
console.log(stringLiteral.length); // logs 3
console.log(stringLiteral['length']); // logs 3
console.log('bar'.length); // logs 3
console.log('bar'['length']); // logs 3