JSFiddle - React, Tailwind, and code Playground

by Michael Seifert

JavaScript

// working
test = (function() {
  test.currentInstance = undefined;
	 
  function test() {
    this.id = 0;
    test.currentInstance = this;
  }


  test.prototype.setId = function(id) {
    this.id = id;
  }

  return test;
})();



var myTest = new test();
myTest.setId(1);
console.log(myTest.id)
console.log(test.currentInstance.id);