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

var myObject = {};

// contain properties inside of myObject representing most of the native JavaScript values

myObject.myFunction = function() {};
myObject.myArray = [];
myObject.myString = 'string';
myObject.myNumber = 33;
myObject.myDate = new Date();
myObject.myRegExp = /a/;
myObject.myNull = null;
myObject.myUndefined = undefined;
myObject.myObject = {};
myObject.myMath_PI = Math.PI;
myObject.myError = new Error('Crap!');

console.log(myObject.myFunction,myObject.myArray,myObject.myString,myObject.myNumber,myObject.myDate,myObject.myRegExp,myObject.myNull,myObject.myNull,myObject.myUndefined,myObject.myObject,myObject.myMath_PI,myObject.myError);

/* works the same with any of the complex objects, for example a function */

var myFunction = function() {};

myFunction.myFunction = function() {};
myFunction.myArray = [];
myFunction.myString = 'string';
myFunction.myNumber = 33;
myFunction.myDate = new Date();
myFunction.myRegExp = /a/;
myFunction.myNull = null;
myFunction.myUndefined = undefined;
myFunction.myObject = {};
myFunction.myMath_PI = Math.PI;
myFunction.myError = new Error('Crap!');

console.log(myFunction.myFunction,myFunction.myArray,myFunction.myString,myFunction.myNumber,myFunction.myDate,myFunction.myRegExp,myFunction.myNull,myFunction.myNull,myFunction.myUndefined,myFunction.myObject,myFunction.myMath_PI,myFunction.myError);