JSFiddle - React, Tailwind, and code Playground

by kbcb

HTML

<div id="test" />

JavaScript

var MyModel = function() {
    var self = this;
    
    self.type = 'XXX';
    self.class = 'YYY';
    
    self.MyFunction = function() {
        self.type = 'YYYY';
    };
};

var testOutput = '';

var modelInstance = new MyModel();
testOutput += 'modelInstance: ' + JSON.stringify(modelInstance) + '<br/>\n';
modelInstance.MyFunction();
testOutput += 'modelInstance after MyFunction(): ' + JSON.stringify(modelInstance) + '<br/>\n';

var secondModelInstance = new MyModel();
testOutput += 'secondModelInstance: ' + JSON.stringify(secondModelInstance) + '<br/>\n';

testOutput += 'secondModelInstance.class: ' + secondModelInstance.class + '<br/>\n';

testOutput += 'typeof secondModelInstance: ' + JSON.stringify(typeof MyModel) + '<br/>\n';

$('#test').html(testOutput);