JSFiddle - React, Tailwind, and code Playground

by caitp

HTML

<pre id="logger"></pre>

JavaScript

var callsites = [];
function tag(cs) {
  callsites.push(cs);
  return callsites.length > 1 ? callsites.every(function(v) {
    return cs === v;
  }).toString() : '';
}

var slice = Array.prototype.slice;
var world;

function $log() {
  var t = slice.call(arguments, 0).join(' ') + '\n';
  logger.appendChild(document.createTextNode(t));
}

var t = "tag`hello, ${world}.`";
$log('eval1', eval(t));
$log('eval1', eval(t));

$log('new Func1', (new Function(t))());
$log('new Func2', (new Function(t))());