JSFiddle - React, Tailwind, and code Playground
by rwaldron
HTML
<script id="code" type="text/x-javascript">
// Will throw: "ReferenceError: bar is not defined"
var foo = bar;
</script>
JavaScript
var code = $("#code").text(),
wrapped = "try { " + code + " } catch(e) { var caught = e; }";
console.log(wrapped);
$.globalEval( wrapped );
// if error was caught, then log it.
console.log( caught && caught );