JSFiddle - React, Tailwind, and code Playground

by jfriend00

JavaScript

"use strict";

class View {
  constructor(options) {
    this.model = options.model;
    this.template = options.template;
  }

  render() {
    log(this.model);
  }
}

var v = new View({model: "a", template: "b"});
v.render();

// utility for displaying output in main window (like console.log() does)
function log(args) {
    var str = "";
    for (var i = 0; i < arguments.length; i++) {
        if (typeof arguments[i] === "object") {
            str += JSON.stringify(arguments[i]);
        } else {
            str += arguments[i];
        }
    }
    var div = document.createElement("div");
    div.innerHTML = str;
    var target = log.id ? document.getElementById(log.id) : document.body;
    target.appendChild(div);
}